Plot and color curves depending on the condition

조회 수: 2 (최근 30일)
CheshireM
CheshireM 2021년 9월 29일
댓글: CheshireM 2021년 9월 30일
I have a cell array Ready, 4x500.
Example, how it looks.
Each cell is a double array, similar structure.
Example of Ready{1,2}.
I want to make a plot for every 5th row in Ready as x-axis, (6,7,8,9) and the sum of 3d row as y-axis(2.4443, 2.4443, 2.4443 in the example).
So, as a result I want to get 4 plots (for every row of cell array Ready), every cell - different color (black, read or green), depending on 7th row (001 - black, 111 - green, 000 - red).
Could you please help me with this?
Thank you very much!

채택된 답변

Kevin Holly
Kevin Holly 2021년 9월 29일
I am unsure what you mean by "he sum of 3d row as y-axis(2.4443, 2.4443, 2.4443 in the example)."
For now I am plotting the 5th row against the 3rd row. Please see below.
for i = 1:size(Ready,1)
figure
title(['Plot for Row ' num2str(i)])
xlabel('X Label')
ylabel('Y Label')
for ii=1:size(Ready,2)
m = Ready{i,ii};
if [m(7,2) m(7,3) m(7,4)] == [0 0 1]
plot(m(5,:),m(3,:),'color','k')
end
if [m(7,2) m(7,3) m(7,4)] == [1 1 1]
plot(m(5,:),m(3,:),'color','g')
end
if [m(7,2) m(7,3) m(7,4)] == [0 0 0]
plot(m(5,:),m(3,:),'color','r')
end
hold on
end
hold off
end
  댓글 수: 8
Kevin Holly
Kevin Holly 2021년 9월 30일
@CheshireM No problem! If you can, I would appreciate it if you would accept this answer.
CheshireM
CheshireM 2021년 9월 30일
Of course! Thank you!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by