From: ragab Rabeiy on
Dear All,

I need help in plotting.
I want to plot 6 lines in one figure from a loop code.
i did that, but all the lines have the same color and symbol.

i need that, every line has different color and symbol.
see this code:

clc
clear
close all
ind=1;
for j=1:6;
for x= 400:400:20000;

t =0.5*sqrt(x)+10*j;

plot (x,t,'-bs') ; hold on; grid on;
ind=ind+1;
end
end

Greetings
Matlab-beginner,
From: Wayne King on
"ragab Rabeiy" <r_rabeiy(a)yahoo.com> wrote in message <hv7n0h$7v4$1(a)fred.mathworks.com>...
> Dear All,
>
> I need help in plotting.
> I want to plot 6 lines in one figure from a loop code.
> i did that, but all the lines have the same color and symbol.
>
> i need that, every line has different color and symbol.
> see this code:
>
> clc
> clear
> close all
> ind=1;
> for j=1:6;
> for x= 400:400:20000;
>
> t =0.5*sqrt(x)+10*j;
>
> plot (x,t,'-bs') ; hold on; grid on;
> ind=ind+1;
> end
> end
>
> Greetings
> Matlab-beginner,

Hi, Welcome to Matlab!

One of many solutions:

x= 400:400:20000;
marks = ['+','^','o'];
colorz = ['b','k','r'];
t = zeros(length(x),3);
for j=1:3;

t(:,j) =0.5*sqrt(x)+10*j;

line(x,t(:,j),'linestyle','-','marker',marks(j),'color',colorz(j));
end


I only did 3, but you can generalize.

Hope that helps,
Wayne
From: Debanga Neog on
Hi,
This can be a generalized solution:

x= 400:400:20000;
marks = ['+','^','o'];
colorz = ['b','g','r'];
t = zeros(length(x),3);
N =5;
for j=1:N;

t(:,j) =0.5*sqrt(x)+10*j;

line(x,t(:,j),'linestyle','-','marker',marks(mod(j,3)+1),'color',colorz(mod(j,3)+1));
end

Thanks to W. King!!!

-DRN
From: ragab Rabeiy on
thank you very much
ragab

"Wayne King" <wmkingty(a)gmail.com> wrote in message <hv7q9h$45p$1(a)fred.mathworks.com>...
> "ragab Rabeiy" <r_rabeiy(a)yahoo.com> wrote in message <hv7n0h$7v4$1(a)fred.mathworks.com>...
> > Dear All,
> >
> > I need help in plotting.
> > I want to plot 6 lines in one figure from a loop code.
> > i did that, but all the lines have the same color and symbol.
> >
> > i need that, every line has different color and symbol.
> > see this code:
> >
> > clc
> > clear
> > close all
> > ind=1;
> > for j=1:6;
> > for x= 400:400:20000;
> >
> > t =0.5*sqrt(x)+10*j;
> >
> > plot (x,t,'-bs') ; hold on; grid on;
> > ind=ind+1;
> > end
> > end
> >
> > Greetings
> > Matlab-beginner,
>
> Hi, Welcome to Matlab!
>
> One of many solutions:
>
> x= 400:400:20000;
> marks = ['+','^','o'];
> colorz = ['b','k','r'];
> t = zeros(length(x),3);
> for j=1:3;
>
> t(:,j) =0.5*sqrt(x)+10*j;
>
> line(x,t(:,j),'linestyle','-','marker',marks(j),'color',colorz(j));
> end
>
>
> I only did 3, but you can generalize.
>
> Hope that helps,
> Wayne
From: Steven Lord on

"Wayne King" <wmkingty(a)gmail.com> wrote in message
news:hv7q9h$45p$1(a)fred.mathworks.com...
> "ragab Rabeiy" <r_rabeiy(a)yahoo.com> wrote in message
> <hv7n0h$7v4$1(a)fred.mathworks.com>...
>> Dear All, I need help in plotting.
>> I want to plot 6 lines in one figure from a loop code.
>> i did that, but all the lines have the same color and symbol.
>>
>> i need that, every line has different color and symbol.

*snip*

> I only did 3, but you can generalize.
> Hope that helps,
> Wayne

As an alternative to Wayne's solution, try replacing "hold on" in your
original code with "hold all".

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/hold.html

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com