Plotting column of a matrix from a string.
Afficher commentaires plus anciens
I have a variable which contains data loaded from a matfile...
loadedContent=load('C:\Users\ringo\AppData\Local\Temp\temp3388979983628797436tmp\mv_20.mat');
in that matfile is a 360000x5 double called dat. I need to plot a column from dat using a char variable. I can plot all of the columns by creating a char variable
plotsall = 'dat';
plot(loadedContent.(num2str(plotsall)));
but if i try
plotcolumn = 'dat(:,1)';
plot(loadedContent.(num2str(plotcolumn)));
i get an error
Reference to non-existent field 'dat(:,1)'.
The only way round it I can think is to actually load the data into the workspace and plot using
plot(eval(plotcolumn));
this works, but using the eval function is never good... i just can't think of a way round it. Any ideas?
If you want/need anymore info as to why i'm doing this, a short version is making gui-->user locates file--->contents of file loaded into a list box--->user selects which data to plot--->if the data has more than one column a popup asks them which column to plot--->data gets plotted.
If you need anymore info, please let me know. Cheers
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!