how can i plot graphs with various colors

for jj = 1:12
col=hsv(12);
[T,Y]=ode45(@solve_for_state_error_nonlinear,[0,sim_time],init_cond,options1);
figure
plot(time,Angle_mag(:,1),'color',col(jj,:));
title('Angle with the magnetic field (deg)');
xlabel('time(s)')
end
This is the code i am using and i am getting the plots as shown in the figure.I need a graph with different colors in the same graph but i am getting different graphs with different colors.
Thanks in advance

Answers (1)

[T,Y]=ode45(@solve_for_state_error_nonlinear,[0,sim_time],init_cond,options1
col=hsv(numel(T));
for jj = 1:numel(T)
plot(T,Y(jj,1),'.','color',col(jj,:));
hold on
end
title('Angle with the magnetic field (deg)');
xlabel('time(s)')

1 Comment

Thx @ Azzi Abdelmalek but what actually happens while calculating [T,Y] is there is a term with (jj) hence i get a different [T,Y] for every value of jj and hence i need to plot angle_mag which is calculated from Y for every jj

Sign in to comment.

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Tags

No tags entered yet.

Asked:

on 4 Oct 2013

Commented:

on 4 Oct 2013

Community Treasure Hunt

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

Start Hunting!