<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264054</link>
    <title>MATLAB Central Newsreader - plot command changing style and color in for loop</title>
    <description>Feed for thread: plot command changing style and color in for loop</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sun, 25 Oct 2009 11:36:01 -0400</pubDate>
      <title>plot command changing style and color in for loop</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264054#689559</link>
      <author>Frankele ele</author>
      <description>Hey there,&lt;br&gt;
&lt;br&gt;
i'm currently wrting on a few matlab files to evaluate the shape of a hystersis loop. &lt;br&gt;
So i got 3 m-files. (input, calculation/simulation, plot)&lt;br&gt;
&lt;br&gt;
What I want to do: I got a formula depending on 7 parameters. And I want to give out a plot which shows me the change of the hystersis loop when changing one parameter. Therefore i created a for loop which is simulating my simulink model 3 times. Everytime the simulink model picks the changed parameter out of the vector i created.&lt;br&gt;
&lt;br&gt;
e.g.&lt;br&gt;
betav=[1, 2, 3]&lt;br&gt;
beta=betav(i)&lt;br&gt;
this way my parameter beta is changed in the simulation&lt;br&gt;
after the simulation, the programm does some calculations with the data comin from the simulation.&lt;br&gt;
&lt;br&gt;
now I want to plot that stuff&lt;br&gt;
so I created a vector&lt;br&gt;
color=['b','g','r']&lt;br&gt;
then there is my for loop for the plot&lt;br&gt;
&lt;br&gt;
for i=1:3&lt;br&gt;
plot(datax(i,:), datay(i,:), color(i));&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
this works fine&lt;br&gt;
but when i want to have something like this&lt;br&gt;
color=[':b',':g',':r']&lt;br&gt;
matlab ignores my input in the color vector and simply prints it in blue lines&lt;br&gt;
what can I do?&lt;br&gt;
I already tried something like&lt;br&gt;
set(gca,'LineStyleOrder',{'-*','-o','-v','-p','-^','-d'}); &lt;br&gt;
but then i get no plot at all :/&lt;br&gt;
&lt;br&gt;
regards Frank</description>
    </item>
    <item>
      <pubDate>Sun, 25 Oct 2009 18:34:01 -0400</pubDate>
      <title>Re: plot command changing style and color in for loop</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264054#689597</link>
      <author>Phil Goddard</author>
      <description>&lt;br&gt;
color=[':b',':g',':r'];&lt;br&gt;
is equivalent to creating the 6 element vector&lt;br&gt;
color =':b:g:r';&lt;br&gt;
&lt;br&gt;
Hence&lt;br&gt;
for i=1:3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;plot(datax(i,:), datay(i,:), color(i));&lt;br&gt;
end&lt;br&gt;
will give you lines using ':', 'b' and then ':', all of which will be blue.&lt;br&gt;
&lt;br&gt;
There are multiple ways of doing what you want, one would be to use cell arrays&lt;br&gt;
&lt;br&gt;
color = {':b',':g',':r'};&lt;br&gt;
for i=1:3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;plot(datax(i,:), datay(i,:), color{i});&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
(Note the curly braces.)&lt;br&gt;
&lt;br&gt;
Phil.</description>
    </item>
  </channel>
</rss>

