How do I extract data from multiple matrices with double variable?
古いコメントを表示
Hello Matlab Community,
I'm new to Matlab programming so I hope the question is not too trivial but I am struggling to find an answer.
I have a series of Matrices containing measurement results, imported into my workspace from as 'm_NN' (NN being the number of the measurement, in this case NN = 10:15.
Each matrix contains the results from 20 canals (so let's write it as n = 1 : N_chan with N_chan=20).
I want to extract each column, so each measurement for each channel and save it as K_n_NN (so e.g. K_6_14 would be the 6th column of the matrix M_014), and save them as doubles in my workspace. Could someone tell me how to do it? My trials with sprintf(M_0) and num2str(n) result only in errors.
Your help would be greatly appreciated!
採用された回答
その他の回答 (1 件)
Image Analyst
2017 年 12 月 14 日
See the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F
and then don't do what you're trying to do. Leave them as matrices, then when you want/need your single column, say in a for loop or somewhere, you can simply extract it and use it then. No need to store all columns forever in a newly created variables with different names.
for k = 10 : 15
thisFileName = sprintf(......
thisM = readtable(thisFileName); % Or csvread(), importdata(), xlsread(), etc.
thisColumn = thisM(:, columnNumber);
% Do something with thisColumn, like plot it, compare it, or whatever.
end
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!