Plot and color curves depending on the condition

1 visualizzazione (ultimi 30 giorni)
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!

Risposta accettata

Kevin Holly
Kevin Holly il 29 Set 2021
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 Commenti
Kevin Holly
Kevin Holly il 30 Set 2021
@CheshireM No problem! If you can, I would appreciate it if you would accept this answer.

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by