From: Mathieu on
"Mathieu " <md3g09(a)soton.ac.uk> wrote in message <i2mdmo$nvo$1(a)fred.mathworks.com>...
>
> > first: do NOT use name the output var of INPUT -> INPUT(!); otherwise, you'll obviously not be able to call this ML function, again...
> >
> > one of the solutions
> >
> > inp=input('month? ','s');
> > % assume the user entered: jan
> > vnam=sprintf('j2%s_avg',inp)
> > % vnam = j2jan_avg
> > % now, use VNAM in your code...
> >
> > also, make sure you're not ...violating... this common-sense rule
> >
> > http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F
> >
> > us
>
> thanks a lot for your help, but the problem kind of remains... this code creates a string variable called vnam that contains the string J2jan_avg.
>
> The fact is that I have in my workspace:
>
> J2jan_avg
> J2feb_avg
> J2mar_avg
> J2apr_avg
>
> and I want to plot the correct variable in function of the input specified by the user. and in the pcolor function, I have to enter the name of a variable that contains the data
>
> >pcolor(longitude,latitude,J2sep_avg(:,:))
>
> I think of something a bit like str2num but instead of changing a string in a number, it would insert a string into a variable name...
> any idea ?
> thanks again!

it works ! THANK YOU !