Path: news.mathworks.com!not-for-mail
From: "Phil Goddard" <philNOSPAM@goddardconsulting.ca>
Newsgroups: comp.soft-sys.matlab
Subject: Re: plot command changing style and color in for loop
Date: Sun, 25 Oct 2009 18:34:01 +0000 (UTC)
Organization: Goddard Consulting
Lines: 21
Message-ID: <hc25mp$31d$1@fred.mathworks.com>
References: <hc1d71$kmg$1@fred.mathworks.com>
Reply-To: "Phil Goddard" <philNOSPAM@goddardconsulting.ca>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1256495641 3117 172.30.248.38 (25 Oct 2009 18:34:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 25 Oct 2009 18:34:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 26433
Xref: news.mathworks.com comp.soft-sys.matlab:579909



color=[':b',':g',':r'];
is equivalent to creating the 6 element vector
color =':b:g:r';

Hence
for i=1:3
   plot(datax(i,:), datay(i,:), color(i));
end
will give you lines using ':', 'b' and then ':', all of which will be blue.

There are multiple ways of doing what you want, one would be to use cell arrays

color = {':b',':g',':r'};
for i=1:3
   plot(datax(i,:), datay(i,:), color{i});
end

(Note the curly braces.)

Phil.