Rank: 5816 based on 17 downloads (last 30 days) and 1 file submitted
photo

Thomas

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by Thomas
Updated   File Tags Downloads
(last 30 days)
Comments Rating
11 Jan 2010 STR2VAR Returns the variable or array of variables, VAR, matching the pattern STR. Author: Thomas workspace 17 4
Comments and Ratings by Thomas View all
Updated File Comments Rating
12 Jan 2010 STR2VAR Returns the variable or array of variables, VAR, matching the pattern STR. Author: Thomas

I was just trying to be nice and explain one example (with the creation of an anonymous variable to pass onto a function) for you. It is meant to be a help using the command line, not for "efficient programming". If you do not find any use for it, so be it.

12 Jan 2010 STR2VAR Returns the variable or array of variables, VAR, matching the pattern STR. Author: Thomas

The way I use it, is to avoid having to write long lines in order to create an array, e.g.:

>> whos
S4A1E01 1x1 17297 struct array
S4A1E02 1x1 15893 struct array
S4A1E03 1x1 19313 struct array
... many more ...
S4A3L10 1x1 15825 struct array
S4A3L12 1x1 16081 struct array
S4A3L13 1x1 14513 struct array

Then I write:
>>my_scatter_plot(str2var('S4*'));

instead of:
>>my_scatter_plot([S4A1E01, ...many more..., S4A3L13]);

Comments and Ratings on Thomas' Files View all
Updated File Comment by Comments Rating
12 Jan 2010 STR2VAR Returns the variable or array of variables, VAR, matching the pattern STR. Author: Thomas Thomas

I was just trying to be nice and explain one example (with the creation of an anonymous variable to pass onto a function) for you. It is meant to be a help using the command line, not for "efficient programming". If you do not find any use for it, so be it.

12 Jan 2010 STR2VAR Returns the variable or array of variables, VAR, matching the pattern STR. Author: Thomas Jos (10584)

One should avoid creating variables like this! Use cell arrays or structs, which allows for both clean and efficient programming.

12 Jan 2010 STR2VAR Returns the variable or array of variables, VAR, matching the pattern STR. Author: Thomas Thomas

The way I use it, is to avoid having to write long lines in order to create an array, e.g.:

>> whos
S4A1E01 1x1 17297 struct array
S4A1E02 1x1 15893 struct array
S4A1E03 1x1 19313 struct array
... many more ...
S4A3L10 1x1 15825 struct array
S4A3L12 1x1 16081 struct array
S4A3L13 1x1 14513 struct array

Then I write:
>>my_scatter_plot(str2var('S4*'));

instead of:
>>my_scatter_plot([S4A1E01, ...many more..., S4A3L13]);

11 Jan 2010 STR2VAR Returns the variable or array of variables, VAR, matching the pattern STR. Author: Thomas Jos (10584)

Can you give an example where this might be useful?

Furthermore, it gives rather cryptic error messages to the end-user when the variables cannot be concatenated:
x1.a = 1 ; x2 = {2} ; str2var('x*')
I suggest to catch these errors.

Contact us