matlab - Plotting arrays from a cell list of strings -
suppose have different rows loaded .mat file (using load filename.mat) containing float numbers following same naming convention, e.g:
file_3try = [ 2.4, 5.2, 7.8 ] file_4try = [ 8.7, 2.5, 4,2 ]  file_5try = [ 11.2, 9.11 ] to plot of these in 1 plot using automation (i have many more rows in example above) created cell containing names of arrays using:
name{l} = sprintf('%s%02i%s','file_',num,'try'); inside loop num numbers in names , l counter starting 1.
but when try plot arrays using example:
plot(name{1})  i error:
error using plot invalid first data argument is there way solve this, or going wrong?
there built in solve this
data = load ( 'filename' ); % load data , store in struct fnames = fieldnames ( data ); ii=1:length(fnames)   plot ( axhandle, data.(fnames{ii}) ); end axhandle handle axes want plot on.  not required practice use it.   if not provided plot command plot on current axes, e.g. gca.
Comments
Post a Comment