Plotting column of a matrix from a string.
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!