<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265003</link>
    <title>MATLAB Central Newsreader - Help with plot and linespec matrix</title>
    <description>Feed for thread: Help with plot and linespec matrix</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>Wed, 04 Nov 2009 18:39:04 -0500</pubDate>
      <title>Help with plot and linespec matrix</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265003#692145</link>
      <author>Kevin </author>
      <description>Hi all,&lt;br&gt;
I'm trying to make a single plot with a single dependent variable and multiple functions and include a linespec matrix or vector to change the linetype for each line. Matlab already changes the color but, for easy differentiation after printing in black and white, I want to change whether the line is solid or dashed or dotted.&lt;br&gt;
&lt;br&gt;
I'm including sample code that creates the kind of plot I want. The problem is that there was a bit of hacking I found on Google to get that done, and I think there might be a more straight-forward and easily expandable way that would look like:&lt;br&gt;
&lt;br&gt;
plot(theta,out,my_lines);&lt;br&gt;
&lt;br&gt;
Where theta is an angle vector, out is a matrix of results, and my_lines would be some kind of linespec matrix.&lt;br&gt;
&lt;br&gt;
Any thoughts would be appreciated!&lt;br&gt;
&lt;br&gt;
Sample code:&lt;br&gt;
close all; clear all;&lt;br&gt;
&lt;br&gt;
theta = 0:360;&lt;br&gt;
phase = [0;120;240];&lt;br&gt;
&lt;br&gt;
out = zeros(length(phase),length(theta));&lt;br&gt;
&lt;br&gt;
for i = 1:length(phase)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;out(i,:) = sind(theta+phase(i));&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
scrsz = get(0,'ScreenSize');% size plots to match sreen&lt;br&gt;
&lt;br&gt;
figure('Position',[0.1*scrsz(3) 0.1*scrsz(4) 0.5*scrsz(3) 0.8*scrsz(4)]);&lt;br&gt;
foo = plot(theta,out);&lt;br&gt;
set(foo(2),'linestyle',':');&lt;br&gt;
set(foo(3),'linestyle','--');&lt;br&gt;
legend(['\theta_{p1} = ' num2str(phase(1)) '?'],...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;['\theta_{p2} = ' num2str(phase(2)) '?'],...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;['\theta_{p3} = ' num2str(phase(3)) '?']);&lt;br&gt;
title('Sine waves with phase angles \theta_{pi}');&lt;br&gt;
xlabel('\theta'); ylabel('sin(\theta + \theta_{pi})');&lt;br&gt;
%saveas(gcf,'output.pdf');</description>
    </item>
  </channel>
</rss>

