Legend does not have the right color every two plots.
Show older comments
%Every even plot inside the "for" has a mismatch in color(and the mismatches have the same color).
%I'm plotting from simulink. Tried fixing using the vector "cor" inthe plot but didn't help.
clear all
close all
clc
legend('off');
legend('show');
Vref=0.1;
gamma=0.1;
Kd=1:1:6;
Kp=1:1:6;
Ki=1:1:6;
cor=[[1 1 0]; [1 0 1]; [0 1 1]; [1 0 0]; [0 1 0]; [0 0 1]; [0 0 0]]
for i = 1:size(Kd,2)
K_d=Kd(i);
for j= 1:size(Kp,2)
K_p=Kp(j);
info=sim('diagrama_blocos');
Vt_out=info.Vt.signals.values(:,1);
Vt_ref_out=info.Vt.signals.values(:,2);
time_out=info.Vt.time;
plot(time_out,Vt_out,'LineWidth',2,'Color', cor(j,:));grid on;hold all;
line([time_out(1),time_out(end)],[Vref,Vref]);
legendInfo{j}=['Kp= ', num2str(K_p)];
title(['Curvas para Kd= ', num2str(K_d)]);
end
legend(legendInfo)
figure()
end

Accepted Answer
More Answers (0)
Categories
Find more on Legend in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!