# Plot cell data from for loop

조회 수: 2(최근 30일)
lena kappa 2022년 4월 12일
댓글: Mathieu NOE 2022년 4월 13일
Hi everyone I have the folllowing code which gives me a cell array y{m,ind} and i would like to plot in the same figure
y{1,1}, y{1,2}, y{1,3}up to y{1,5} but i cant figure out how to do it.
Preferably i would like to be able to do this for multiple values of m at the same time(i.e. m=1, m=3, ..).
So to have lets say 3 figures for m=1, m=3 and m=5 and in each on of these figures to have the 5 y{m,ind} plots.
I hope i explained it clearly
outLoop = [2,4,8];
outLoop1 = [1, 3, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
for r = 1 : numel(outLoop)
r = outLoop(r);
for m = 1 : numel(outLoop1)
m = outLoop1(m);
for ind=1:5
y{m,ind} = mean(vertcat(y{:,r,m,ind}),1);
end
end
end
##### 댓글 수: 2표시숨기기 이전 댓글 수: 1
lena kappa 2022년 4월 12일
al= [2,4,8]
but eitherway this is part of a bigger code which i can't upload since i can't upload the corresponding images it analyses.
Thank you for your answer i do know about the command plot but i can't use it correctly for cell array.

댓글을 달려면 로그인하십시오.

### 채택된 답변

Mathieu NOE 2022년 4월 12일
hello
maybe this ?
I replaced the " mean(vertcat(y{:,r,m,ind}),1) " by a simple random number
clc
clearvars
outLoop = [2,4,8];
outLoop1 = [1, 3, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
al= [2,4,8]
for cr = 1 : numel(outLoop)
r = outLoop(cr);
for cm = 1 : numel(outLoop1)
m = outLoop1(cm);
for ind=1:5
%y{m,ind} = mean(vertcat(y{:,r,m,ind}),1);
y{m,ind} = rand(1,1);
end
figure(cm)
plot([y{m,:}])
end
end
##### 댓글 수: 2표시숨기기 이전 댓글 수: 1
Mathieu NOE 2022년 4월 13일
My pleasure !

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!