Re: Renaming variables using strings



[This followup was posted to comp.soft-sys.matlab and a copy was sent to
the cited author.]

In article <ef24a62.-1@xxxxxxxxxxxxxxxx>, kristjan.tabri@xxxxxx says...
> Hi all,
> I have a big database with several variables inside. Now I would like
> to assign some other names for the variables. One script makes a
> strings of these variable names according to some routine. For
> example, i have a variable in database called F101 and the script
> makes a string 'F101'. I would like to rename the variable F101 as
> dataF. As I have the variable name just as an automatically
> generated string (by ['F','101'], I do not know how to rename the
> variable. Commands dataF='F101' and dataF=str2num('F101') do not work
> in such a case. When dataF='F101' is used the existing variable is
> just rewritten and obtains a value of the string and str2num('F101')
> does not work as F101 cannot be turned into a number.
>
> Any idea how to do it?
>
> Regards,
> kristjan
>


See this article in the MATLAB FAQ:

http://www.mit.edu/~pwb/cssm/matlab-faq_4.html#evalcell

and also this article: http://blogs.mathworks.com/loren/?p=15
on my blog.

>From these, you can find out how to put the data into cell arrays or
structures instead of naming the variables using eval.

--Loren

.



Relevant Pages


Loading