How to display all values from the for loop in one variable

Z= [x1 x2 x3 x4 x5 x6 x7];
size(Z)= 400 7;
for i=1:7
m=Z(:,i:i)
end

回答 (2 件)

Mark Sherstan
Mark Sherstan 2018 年 11 月 30 日

0 投票

Try this (I had to make up your z values).
Z = randi(5,[400,7]);
for ii = 1:7
m{ii} = Z(:,ii:ii);
end
If you wanted to retrieve your 3rd value do the following:
m{3}
madhan ravi
madhan ravi 2018 年 12 月 1 日
編集済み: madhan ravi 2018 年 12 月 1 日

0 投票

Z= [x1 x2 x3 x4 x5 x6 x7];
%size(Z)= 400 7;
m=cell(size(Z,1),size(Z,2)); %PREALLOCATION for speed and efficiency
for i=1:7
m{i}=Z(:,i);
end
celldisp(m)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

タグ

質問済み:

2018 年 11 月 30 日

編集済み:

2018 年 12 月 1 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by