Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline Lupus the Canine  
#1 Posted : 07 July 2023 05:12:48(UTC)
Lupus the Canine

Rank: Newbie

Groups: Registered
Joined: 02/07/2023(UTC)
Posts: 6
Poland

Is it possible to procedurally define variables from strings?
I want to load data to a lot of sets of variables with names following a pattern preferably without doing that manually.
Is there a better way than:
Zrzut ekranu 2023-07-07 041452.png
example.sm (5kb) downloaded 5 time(s).?

Edited by user 07 July 2023 05:15:56(UTC)  | Reason: added the image.

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Davide Carpi  
#2 Posted : 07 July 2023 11:06:15(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,648
Man
Italy
Location: Italy

Was thanked: 1331 time(s) in 876 post(s)
That's one of the other options.

2023-07-07 10_05_43-SMath Solver - [example.sm_].png
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline Lupus the Canine  
#3 Posted : 07 July 2023 22:18:37(UTC)
Lupus the Canine

Rank: Newbie

Groups: Registered
Joined: 02/07/2023(UTC)
Posts: 6
Poland

Originally Posted by: Davide Carpi Go to Quoted Post
That's one of the other options.

2023-07-07 10_05_43-SMath Solver - [example.sm_].png


Thanks, unfortunately value to be assigned is supposed to come from somewhere else, z was just an example because I didn't want to make example with large vectors or matrices to be assigned.

I was looking for a function that would turn a string into a variable that can be used as lhs operand in assignment.
Offline mkraska  
#4 Posted : 08 July 2023 02:02:53(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,988
Germany

Was thanked: 1124 time(s) in 721 post(s)
If the value to be assigned is an ordinary expression, then just convert it to a string before using the above-mentioned methods.

asg.sm (5kb) downloaded 6 time(s).
asg.png
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline overlord  
#5 Posted : 08 July 2023 05:52:52(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,128
Turkey

Was thanked: 509 time(s) in 339 post(s)
Originally Posted by: Lupus the Canine Go to Quoted Post
Thanks, unfortunately value to be assigned is supposed to come from somewhere else, z was just an example because I didn't want to make example with large vectors or matrices to be assigned.

Something like this?
z can be anything and come from anywhere.
As long as it has same length with v.

Regards

StrAssign.sm (7kb) downloaded 6 time(s).

Click to enlarge

Edited by user 08 July 2023 16:25:06(UTC)  | Reason: Not specified

Offline Lupus the Canine  
#6 Posted : 08 July 2023 23:48:00(UTC)
Lupus the Canine

Rank: Newbie

Groups: Registered
Joined: 02/07/2023(UTC)
Posts: 6
Poland

Thank you for your help makraska and overlord.
This look great. I will throw eval in there to be sure it is numeric assignment.
Offline Jean Giraud  
#7 Posted : 10 July 2023 15:53:28(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Lupus the Canine Go to Quoted Post
Thanks, unfortunately value to be assigned is supposed to come from somewhere else ...
I was looking for a function that would turn a string into a variable that can be used as operand in assignment.

algo(col) will deal with mixed import matrix.
You can code to convert mixed or numeric or string.
Select the desired matrix-col.
Subsequently, set your maths.
The attached document SS 6179, I checked it opens 30405.
Please, confirm it opens on your system.
Cheers ... Jean.

Maths Convert-str2num COL algo.sm (6kb) downloaded 2 time(s).
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.