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 marks2c  
#1 Posted : 31 December 2022 08:33:45(UTC)
marks2c


Rank: Advanced Member

Groups: Registered
Joined: 01/04/2020(UTC)
Posts: 85
New Zealand
Location: Wellington

Was thanked: 4 time(s) in 3 post(s)
Is there a function or method that would allow a string (or variable name) located in a matrix element to be used as the name to define a variable?

Something like this:

Str2Var.png

Thank you!

Edited by user 31 December 2022 10:24:54(UTC)  | Reason: Not specified

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

Offline uni  
#2 Posted : 31 December 2022 10:28:45(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

Was thanked: 1274 time(s) in 745 post(s)
str2num.png str2num_un.png

str2num_full.png

Edited by user 31 December 2022 10:46:33(UTC)  | Reason: Not specified

Russia ☭ forever
Viacheslav N. Mezentsev
thanks 4 users thanked uni for this useful post.
on 31/12/2022(UTC),  on 31/12/2022(UTC),  on 31/12/2022(UTC),  on 01/01/2023(UTC)
Offline marks2c  
#3 Posted : 31 December 2022 12:43:07(UTC)
marks2c


Rank: Advanced Member

Groups: Registered
Joined: 01/04/2020(UTC)
Posts: 85
New Zealand
Location: Wellington

Was thanked: 4 time(s) in 3 post(s)
Thank you so much uni!

Edited by user 31 December 2022 12:49:57(UTC)  | Reason: Not specified

Offline loha  
#4 Posted : 01 January 2023 18:51:50(UTC)
loha


Rank: Advanced Member

Groups: Registered
Joined: 13/09/2011(UTC)
Posts: 63
Location: Kolkata

Was thanked: 9 time(s) in 9 post(s)
WOW!!!
Offline mkraska  
#5 Posted : 02 January 2023 12:31:00(UTC)
mkraska


Rank: Advanced Member

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

Was thanked: 1124 time(s) in 721 post(s)
Originally Posted by: marks2c Go to Quoted Post
Is there a function or method that would allow a string (or variable name) located in a matrix element to be used as the name to define a variable?


You can also use the Assign() function of the Maxima Plugin (this should work even without Maxima installed).

It converts boolean equations into assignments.

In the case of strings you still need to apply str2num()

Assign.sm (5kb) downloaded 12 time(s).
assign.PNG

Edited by user 02 January 2023 13:04:16(UTC)  | Reason: Not specified

Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 2 users thanked mkraska for this useful post.
on 02/01/2023(UTC),  on 02/01/2023(UTC)
Offline marks2c  
#6 Posted : 05 January 2023 02:02:47(UTC)
marks2c


Rank: Advanced Member

Groups: Registered
Joined: 01/04/2020(UTC)
Posts: 85
New Zealand
Location: Wellington

Was thanked: 4 time(s) in 3 post(s)
Some odd behavior here. When the "=" evaluation is removed the Assign() function breaks:

Assign odd behaviour.png
Assign odd behaviour.sm (4kb) downloaded 1 time(s).

Any thoughts?

I'm hoping to be able to assign multiple variables from a matrix like this:
Assign For Loop.png
Assign For Loop Broken.sm (6kb) downloaded 5 time(s).

Edited by user 05 January 2023 02:36:10(UTC)  | Reason: Not specified

Offline churichuro  
#7 Posted : 05 January 2023 03:47:22(UTC)
churichuro


Rank: Advanced Member

Groups: Registered
Joined: 27/03/2019(UTC)
Posts: 75
Mexico
Location: coah

Was thanked: 27 time(s) in 22 post(s)
a small workaround, could be to place the for inside a line command and return a false token value, it is not very clean but it works as far as I can see.



I think the assign command is not evaluated immediately, but has a delayed evaluation, which somehow only takes place after using the "=" symbol.

Edited by user 05 January 2023 03:49:54(UTC)  | Reason: Not specified

thanks 1 user thanked churichuro for this useful post.
on 05/01/2023(UTC)
Offline overlord  
#8 Posted : 05 January 2023 17:30:01(UTC)
overlord


Rank: Advanced Member

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

Was thanked: 507 time(s) in 338 post(s)
Originally Posted by: mkraska Go to Quoted Post
You can also use the Assign() function of the Maxima Plugin (this should work even without Maxima installed).

Assign() is a useful function and it doesn't need Maxima as you have indicated.
I don't (can't) use Maxima but I need Assign() sometimes.
And its codes have zero relation with Maxima functions.

This is why I suggested sometime ago that it could have relocated in another collective plugin.
CustomFunctions plugin is a good candidate for this purpose.
But I am not persistence, it is what it is.
Author of these plugins choose it this way.

Regards
thanks 1 user thanked overlord for this useful post.
on 06/01/2023(UTC)
Offline mkraska  
#9 Posted : 05 January 2023 22:57:04(UTC)
mkraska


Rank: Advanced Member

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

Was thanked: 1124 time(s) in 721 post(s)
Originally Posted by: marks2c Go to Quoted Post
Some odd behavior here. When the "=" evaluation is removed the Assign() function breaks:

Assign odd behaviour.png
Assign odd behaviour.sm (4kb) downloaded 1 time(s).

Any thoughts?

I'm hoping to be able to assign multiple variables from a matrix like this:
Assign For Loop.png
Assign For Loop Broken.sm (6kb) downloaded 5 time(s).


Two hints:

- The Assign function needs to be executed in order to do it's work, either by assigning the result to some dummy variable or by requesting display of the result.
- You don't need a loop, Assign() can handle vector arguments

Blatt10.png
Blatt10.sm (6kb) downloaded 3 time(s).
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 06/01/2023(UTC)
Offline mkraska  
#10 Posted : 05 January 2023 23:22:41(UTC)
mkraska


Rank: Advanced Member

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

Was thanked: 1124 time(s) in 721 post(s)
Originally Posted by: overlord Go to Quoted Post
Originally Posted by: mkraska Go to Quoted Post
You can also use the Assign() function of the Maxima Plugin (this should work even without Maxima installed).

Assign() is a useful function and it doesn't need Maxima as you have indicated.
I don't (can't) use Maxima but I need Assign() sometimes.
And its codes have zero relation with Maxima functions.

This is why I suggested sometime ago that it could have relocated in another collective plugin.
CustomFunctions plugin is a good candidate for this purpose.
But I am not persistence, it is what it is.
Author of these plugins choose it this way.

Regards


In general I don't care where Assign() is defined. It is in the Maxima plugin, because I needed a neat way to make use of results from Maxima functions like algebraic or ode solvers.

Yet I don't think that it would be a good idea to remove functions from plugins, because this would break the dependency management of existing sheets.

I don't know what happens if the same function is defined in multiple plugins. Would SMath crash? If not, which definition is used if both plugins are installed? One would see this in the dynamic help, but how to control?

BTW, I think that some day I'll revisit the Maxima plugin and if I get some help with a linux development tool chain and work flow I could perhaps make the plugin work also under linux. But that would require at least two months of full time work without distractions, because I would need to learn C# anew from scratch.

If someone is a master in C# I am happy to assist in refactoring and bug fixing of the plugin by providing the specifications and unit tests.

I'd be more comfortable with python or javascript but to my knowledge these aren't options for making plugins.
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 06/01/2023(UTC)
Offline Razonar  
#11 Posted : 06 January 2023 08:15:05(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Hi. This could be another option.

Clipboard01.png

MyAssign 2.sm (11kb) downloaded 14 time(s).

Best regards.
Alvaro.

Edited by user 06 January 2023 11:44:35(UTC)  | Reason: Example added.

thanks 7 users thanked Razonar for this useful post.
on 06/01/2023(UTC),  on 06/01/2023(UTC),  on 06/01/2023(UTC),  on 06/01/2023(UTC),  on 06/01/2023(UTC),  on 06/01/2023(UTC),  on 27/02/2023(UTC)
Offline churichuro  
#12 Posted : 06 January 2023 22:25:18(UTC)
churichuro


Rank: Advanced Member

Groups: Registered
Joined: 27/03/2019(UTC)
Posts: 75
Mexico
Location: coah

Was thanked: 27 time(s) in 22 post(s)
@Razonar, as usual with you, you give imaginative and useful solutions, it's great when people share their knowledge and help others, and with such a high technical level. thanks and congratulations.

I have a folder on my computer exclusively for the spreadsheets you share.

Edited by user 06 January 2023 22:28:08(UTC)  | Reason: Not specified

thanks 2 users thanked churichuro for this useful post.
on 06/01/2023(UTC),  on 07/01/2023(UTC)
Offline alyles  
#13 Posted : 06 January 2023 22:42:15(UTC)
alyles


Rank: Advanced Member

Groups: Registered
Joined: 23/03/2016(UTC)
Posts: 276
United States

Was thanked: 91 time(s) in 57 post(s)
In the event you may want to add descriptions to these definitions... a related thread:
https://en.smath.com/for...ription-to-Variable.aspx

It's a work around, but potentially useful.
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
thanks 3 users thanked alyles for this useful post.
on 06/01/2023(UTC),  on 07/01/2023(UTC),  on 07/01/2023(UTC)
Offline marks2c  
#14 Posted : 06 January 2023 22:43:00(UTC)
marks2c


Rank: Advanced Member

Groups: Registered
Joined: 01/04/2020(UTC)
Posts: 85
New Zealand
Location: Wellington

Was thanked: 4 time(s) in 3 post(s)
Originally Posted by: churichuro Go to Quoted Post
@Razonar, as usual with you, you give imaginative and useful solutions, it's great when people share their knowledge and help others, and with such a high technical level. thanks and congratulations.

I have a folder on my computer exclusively for the spreadsheets you share.


Yes indeed. Likewise. What churichuro said!
thanks 1 user thanked marks2c for this useful post.
on 07/01/2023(UTC)
Offline Razonar  
#15 Posted : 07 January 2023 05:11:34(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Thanks guys. I sincerely appreciate that.

Best regards.
Alvaro.
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.