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일
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일
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 Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

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