Rank: Advanced Member Groups: Registered
Joined: 18/05/2011(UTC) Posts: 36
Was thanked: 3 time(s) in 3 post(s)
|
Hey all,
I've been trying to build a program that will return the type a variable is.
Basically, the function is an expansion of the IsString function, such that there is,
IsMatrix IsNumber IsSystem
etc..
I've attempted to accomplish this with num2str declarations and then seeing if there exists a string of "mat(" in the beginning. However, due to the problems of num2str 'ing matrices, this method fails. As does any other method i've tried.
I feel the best way to accomplish the variable type would be by building a plugin, however, my plugin building skills aren't up to the task. :/
-Pete
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,653 Location: Italy Was thanked: 1340 time(s) in 879 post(s)
|
Originally Posted by: sublim21 Hey all,
I've been trying to build a program that will return the type a variable is.
Basically, the function is an expansion of the IsString function, such that there is,
IsMatrix IsNumber IsSystem
etc..
I've attempted to accomplish this with num2str declarations and then seeing if there exists a string of "mat(" in the beginning. However, due to the problems of num2str 'ing matrices, this method fails. As does any other method i've tried.
I feel the best way to accomplish the variable type would be by building a plugin, however, my plugin building skills aren't up to the task. :/
-Pete You can try to use/enhance the IsScalar() and IsMatrix() functions of varManager snippet (updated to fix an issue in IsArray(#)). EDIT: If you are writing a plugin you can use something like the getNumOfElements function in StatisticalTools or NonlinearSolvers plugins best regards, w3b5urf3r Edited by user 08 January 2013 22:10:46(UTC)
| Reason: Not specified Davide Carpi attached the following image(s): |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 18/05/2011(UTC) Posts: 36
Was thanked: 3 time(s) in 3 post(s)
|
Originally Posted by: w3b5urf3r_reloaded Originally Posted by: sublim21 Hey all,
I've been trying to build a program that will return the type a variable is.
Basically, the function is an expansion of the IsString function, such that there is,
IsMatrix IsNumber IsSystem
etc..
I've attempted to accomplish this with num2str declarations and then seeing if there exists a string of "mat(" in the beginning. However, due to the problems of num2str 'ing matrices, this method fails. As does any other method i've tried.
I feel the best way to accomplish the variable type would be by building a plugin, however, my plugin building skills aren't up to the task. :/
-Pete You can try to use/enhance the IsScalar() and IsMatrix() functions of varManager snippet (updated to fix an issue in IsArray(#)). EDIT: If you are writing a plugin you can use something like the getNumOfElements function in StatisticalTools or NonlinearSolvers plugins best regards, w3b5urf3r
|
|
|
|
Rank: Member Groups: Registered
Joined: 19/01/2012(UTC) Posts: 12 Was thanked: 3 time(s) in 2 post(s)
|
Hi, I started a new PlugIn Project called FunctionBox for SMath. To bring it to life, I added the three requested functions - IsMatrix - IsSystem - IsNumber I did a lot of SMath plugin programming in the past and will contribute to the SMath project by providing some helpful plugins. In the near future I will create a Wiki page for the FunctionBox where I describe the already available functions. Also a post in this forum related to the plugin would be good to discuss new features. So, find attached the FunctionBox.dll plugin and feel free to test it and provide feedback. Have fun, Infinity File Attachment(s): Infinity attached the following image(s):
|
2 users thanked Infinity for this useful post.
|
on 09/01/2013(UTC), on 09/01/2013(UTC)
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,653 Location: Italy Was thanked: 1340 time(s) in 879 post(s)
|
Hi Infinity I'm very glad that you came back with a new plugin Just as a feedback the IsNumber fails evaluating infinity and imaginary unit and there are some issues with single elements arrays/systems best regards, w3b5urf3r Edited by user 09 January 2013 00:43:12(UTC)
| Reason: Not specified File Attachment(s): Davide Carpi attached the following image(s): |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Administration Groups: Registered, Advanced Member Joined: 23/06/2009(UTC) Posts: 1,740 Was thanked: 318 time(s) in 268 post(s)
|
Originally Posted by: Infinity I did a lot of SMath plugin programming in the past and will contribute to the SMath project by providing some helpful plugins. In the near future I will create a Wiki page for the FunctionBox where I describe the already available functions. Also a post in this forum related to the plugin would be good to discuss new features.
Thank you Infinity for your efforts As far as I could see, user made plugins started to grow in numbers . There are not to many of them yet, but I've already feel that I start losing the track of them mainly because they are scattered here on the Forum - most of them are in "Samples" forum and mixed with some other examples of using SMath . w3b5urf3r is trying to make a list of plugins and links to them on Wiki page PLUGINS. Essentially, we just need DLL's with accompanied help files in order to use these plugins and, therefore, I suppose that a new dedicated Forum "User plugins" might be more appropriate for this. Any comments about it? Regards, Radovan |
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!" |
1 user thanked omorr for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,653 Location: Italy Was thanked: 1340 time(s) in 879 post(s)
|
Originally Posted by: omorr Thank you Infinity for your efforts As far as I could see, user made plugins started to grow in numbers . There are not to many of them yet, but I've already feel that I start losing the track of them mainly because they are scattered here on the Forum - most of them are in "Samples" forum and mixed with some other examples of using SMath . w3b5urf3r is trying to make a list of plugins and links to them on Wiki page PLUGINS. Essentially, we just need DLL's with accompanied help files in order to use these plugins and, therefore, I suppose that a new dedicated Forum "User plugins" might be more appropriate for this. Any comments about it? Regards, Radovan I agree with you, I think that a dedicated forum/sub-forum is desirable |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 18/05/2011(UTC) Posts: 36
Was thanked: 3 time(s) in 3 post(s)
|
Updated the whatIs function to handle infinity and others. Checked to make sure correct output will be given regardless of optimization option. Corrected sheet is attached. I also second the idea of creating a plugin forum. Also, if we're going to create a database of plugins, and snippets, then i suggest we use couchdb as the database software to hold the code.
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,653 Location: Italy Was thanked: 1340 time(s) in 879 post(s)
|
Originally Posted by: sublim21 Updated the whatIs function to handle infinity and others. Checked to make sure correct output will be given regardless of optimization option. Corrected sheet is attached.
I also second the idea of creating a plugin forum.
Also, if we're going to create a database of plugins, and snippets, then i suggest we use couchdb as the database software to hold the code. Good, also a snippet sub-forum it's not a bad idea! There still remain some other issues in your snippet (see the snapshot) regards, w3b5urf3r Davide Carpi attached the following image(s): |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 18/05/2011(UTC) Posts: 36
Was thanked: 3 time(s) in 3 post(s)
|
Hey websurfer, You're correct about the error. I've fixed the sheet and have attached it below. It'll work for everything i've tested it for, except strings with leading spaces " a". Personally i don't like how the sheet is laid out. Duck typing the solution is a bad idea. As is the weird nested function solution, but i can't do a better solution until the num2str with spaces and other characters is fixed. for now, it is highly recommended that you stick to A-z, 0-9, and _ until the bugs can be worked out. Speaking of which, in your sheets websurfer, i noticed you use #var inside functions, whats the reason for that? -Pete
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,653 Location: Italy Was thanked: 1340 time(s) in 879 post(s)
|
Originally Posted by: sublim21 Hey websurfer,
You're correct about the error. I've fixed the sheet and have attached it below.
It'll work for everything i've tested it for, except strings with leading spaces " a".
Personally i don't like how the sheet is laid out. Duck typing the solution is a bad idea. As is the weird nested function solution, but i can't do a better solution until the num2str with spaces and other characters is fixed.
for now, it is highly recommended that you stick to A-z, 0-9, and _ until the bugs can be worked out.
Speaking of which, in your sheets websurfer, i noticed you use #var inside functions, whats the reason for that?
-Pete Good ^__^ I think that a better and strong variable type identification will be implemented (soon or later) in the SMath executables, but at least for now our snippets and plugins could be a good help for users. Sometimes I use #var or _var to distinguish between local and global variables. It's not really required but sometimes could be useful (especially for large scripts debugging). regards, w3b5urf3r P.S. here there's a new wiki page with a list of compiled PLUGINS. |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 18/05/2011(UTC) Posts: 36
Was thanked: 3 time(s) in 3 post(s)
|
That's a good programming practice websurfer.
Thanks for the plugin link as well.
-Pete
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 06/02/2013(UTC) Posts: 5 Location: at home Was thanked: 1 time(s) in 1 post(s)
|
A plug-in repository would get my vote! if you decide to go down this route, might I suggest a plug-in manager plug-in such as is common in a lot of software. I would also suggest a rating system for plug-ins to indicate the maturity of a plug-in.
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,653 Location: Italy Was thanked: 1340 time(s) in 879 post(s)
|
Originally Posted by: stevec A plug-in repository would get my vote! if you decide to go down this route, might I suggest a plug-in manager plug-in such as is common in a lot of software. I would also suggest a rating system for plug-ins to indicate the maturity of a plug-in. You can browse the repository clicking on the "Code" button on the top of the page. Using Tortoise SVN or other SVN tools you can see more details about each plugin. regards, w3b5urf3r Davide Carpi attached the following image(s): |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
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.