Plotting column of a matrix from a string.
古いコメントを表示
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
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!