Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
verify matlab function

Subject: verify matlab function

From: Veda

Date: 4 Jun, 2013 01:04:12

Message: 1 of 4

Dear Matlab experts,
I wrote a script to plot multiple data in different colors and line styles as follows
plot(xt,MEGplot_acrsubj(:,1),'Color',[255/255,0/255,0/255],'LineStyle','-',xt,MEGplot_acrsubj(:,2),'Color',[255/255,0/255,0/255],'LineStyle',':',...
    xt,MEGplot_acrsubj(:,3),'Color',[0/255,204/255,204/255],'LineStyle','-',xt,MEGplot_acrsubj(:,4),'Color',[0/255,204/255,204/255],'LineStyle',':')

Matlab returned:
??? Error using ==> plot
String argument is an unknown option.

I don't see why it won't work. Could anyone help me out here? Thanks!

Sincerely,
Veda

Subject: verify matlab function

From: TideMan

Date: 4 Jun, 2013 01:33:43

Message: 2 of 4

On Tuesday, June 4, 2013 1:04:12 PM UTC+12, Veda wrote:
> Dear Matlab experts,
>
> I wrote a script to plot multiple data in different colors and line styles as follows
>
> plot(xt,MEGplot_acrsubj(:,1),'Color',[255/255,0/255,0/255],'LineStyle','-',xt,MEGplot_acrsubj(:,2),'Color',[255/255,0/255,0/255],'LineStyle',':',...
>
> xt,MEGplot_acrsubj(:,3),'Color',[0/255,204/255,204/255],'LineStyle','-',xt,MEGplot_acrsubj(:,4),'Color',[0/255,204/255,204/255],'LineStyle',':')
>
>
>
> Matlab returned:
>
> ??? Error using ==> plot
>
> String argument is an unknown option.
>
>
>
> I don't see why it won't work. Could anyone help me out here? Thanks!
>
>
>
> Sincerely,
>
> Veda

AFAIK, you can't concatenate plot commands like that.
Do it this way instead:
plot(x,y,'r-')
hold on
plot(x1,y1,'b--')
etc

hold off
In other words put each plot command on a separate line, using hold on to ensure they overplot.

Also, a better style which is easier to follow is to put the options on separate lines like this:
plot(xt,MEGplot_acrsubj(:,1),...
    'Color',[255/255,0/255,0/255],...
    'LineStyle','-')

Subject: verify matlab function

From: Nasser M. Abbasi

Date: 4 Jun, 2013 06:18:51

Message: 3 of 4

On 6/3/2013 8:04 PM, Veda wrote:
> Dear Matlab experts,
> I wrote a script to plot multiple data in different colors and line styles as follows
> plot(xt,MEGplot_acrsubj(:,1),'Color',[255/255,0/255,0/255],'LineStyle','-',
>xt,MEGplot_acrsubj(:,2),'Color',[255/255,0/255,0/255],'LineStyle',':',...
> xt,MEGplot_acrsubj(:,3),'Color',[0/255,204/255,204/255],'LineStyle',
>'-',xt,MEGplot_acrsubj(:,4),'Color',[0/255,204/255,204/255],'LineStyle',':')
>
> Matlab returned:
> ??? Error using ==> plot
> String argument is an unknown option.
>
> I don't see why it won't work. Could anyone help me out here? Thanks!
>
> Sincerely,
> Veda
>

I do not know, but by trial and error it looks like one can't use the named
properties 'Color', 'LineStyle' etc.. with multiple data sets. It is
confusing plot

---------------------
x=0:.1:1;
plot(x,sin(x),'LineStyle','-',x,cos(x),'LineStyle','-')
Error using plot
String argument is an unknown option.
-----------------------

---------------------
x=0:.1:1; plot(x,sin(x),'Color',[1,0,0],x,cos(x),'Color',[2,0,0])
Error using plot
Vectors must be the same lengths.
------------------------

But using named colors works:

------------------
x=0:.1:1;
plot(x,sin(x),'r',x,cos(x),'k')
------------------

There might be a way around this, I do not know now.

--Nasser

Subject: verify matlab function

From: Steven_Lord

Date: 4 Jun, 2013 14:18:38

Message: 4 of 4



"Nasser M. Abbasi" <nma@12000.org> wrote in message
news:kok0s9$ahe$1@speranza.aioe.org...
> On 6/3/2013 8:04 PM, Veda wrote:
>> Dear Matlab experts,
>> I wrote a script to plot multiple data in different colors and line
>> styles as follows
>> plot(xt,MEGplot_acrsubj(:,1),'Color',[255/255,0/255,0/255],'LineStyle','-',
>>xt,MEGplot_acrsubj(:,2),'Color',[255/255,0/255,0/255],'LineStyle',':',...
>> xt,MEGplot_acrsubj(:,3),'Color',[0/255,204/255,204/255],'LineStyle',
>>'-',xt,MEGplot_acrsubj(:,4),'Color',[0/255,204/255,204/255],'LineStyle',':')
>>
>> Matlab returned:
>> ??? Error using ==> plot
>> String argument is an unknown option.
>>
>> I don't see why it won't work. Could anyone help me out here? Thanks!
>>
>> Sincerely,
>> Veda
>>
>
> I do not know, but by trial and error it looks like one can't use the
> named
> properties 'Color', 'LineStyle' etc.. with multiple data sets. It is
> confusing plot

You can use property name/value pairs in a PLOT command that plots multiple
data sets. What you _can't_ do that the OP was trying to do was interleave
data sets to be plotted and property name/value pairs.

http://www.mathworks.com/help/matlab/ref/plot.html

"plot(...,'PropertyName',PropertyValue,...) manipulates plot characteristics
by setting lineseries properties (of lineseries graphics objects created by
plot). Enter properties as one or more name-value pairs. Property name-value
pairs apply to all the lines plotted. You cannot specify name-value pairs
for each set of data."

x = 0:0.1:2*pi;
y1 = cos(x);
y2 = sin(x);
plot(x, y1, x, y2, 'Color', 'r')

Two ways to accomplish what the OP wanted are the HOLD option TideMan posted
or using SET after the fact.

x = 0:0.1:2*pi;
y1 = cos(x);
y2 = sin(x);
thelines = plot(x, y1, x, y2);
set(thelines(1), 'Color', 'r');
set(thelines(2), 'Color', 'b');

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us