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:
Is it possible to vectorize LineProperties of a plot object?

Subject: Is it possible to vectorize LineProperties of a plot object?

From: Gustavo Morales

Date: 4 Nov, 2009 00:58:03

Message: 1 of 4

I'd like to do something like this:
>> X = [1, 2, 3]; Y = [2, 2.5, 2.9]; %for example
>> plot(X,Y,'o','MarkerSize',[20, 10, 15]);

but it causes an error:
??? Error using ==> plot
Value must be scalar

I don't want to use a for loop to asign a MarkerSize to each point (xi,yi).
I'd like to vectorize this process. ?Is it possible?

Subject: Is it possible to vectorize LineProperties of a plot object?

From: Pekka Kumpulainen

Date: 4 Nov, 2009 11:36:01

Message: 2 of 4

"Gustavo Morales" <gustavo.morales.2000@gmail.com> wrote in message <hcqjir$3vf$1@fred.mathworks.com>...
> I'd like to do something like this:
> >> X = [1, 2, 3]; Y = [2, 2.5, 2.9]; %for example
> >> plot(X,Y,'o','MarkerSize',[20, 10, 15]);
>
> but it causes an error:
> ??? Error using ==> plot
> Value must be scalar
>
> I don't want to use a for loop to asign a MarkerSize to each point (xi,yi).
> I'd like to vectorize this process. ?Is it possible?

One line object can have only one MarkerSize. If you want different sizes you will have to have separate objects for each. Easy to write your own function for that though.
I may have done the same thing somewhere in past, I think, or something very similar anyway..

Subject: Is it possible to vectorize LineProperties of a plot object?

From: Steven Lord

Date: 4 Nov, 2009 15:08:42

Message: 3 of 4


"Pekka Kumpulainen" <pekka.nospam.kumpulainen@tut.please.fi> wrote in
message news:hcrov1$r76$1@fred.mathworks.com...
> "Gustavo Morales" <gustavo.morales.2000@gmail.com> wrote in message
> <hcqjir$3vf$1@fred.mathworks.com>...
>> I'd like to do something like this:
>> >> X = [1, 2, 3]; Y = [2, 2.5, 2.9]; %for example
>> >> plot(X,Y,'o','MarkerSize',[20, 10, 15]);
>>
>> but it causes an error:
>> ??? Error using ==> plot
>> Value must be scalar
>>
>> I don't want to use a for loop to asign a MarkerSize to each point
>> (xi,yi).
>> I'd like to vectorize this process. ?Is it possible?
>
> One line object can have only one MarkerSize. If you want different sizes
> you will have to have separate objects for each. Easy to write your own
> function for that though.
> I may have done the same thing somewhere in past, I think, or something
> very similar anyway..

If the OP just wants the markers, use SCATTER.

If the OP wants markers of varying sizes and a line connecting them, use
PLOT without a marker, HOLD ON, and use SCATTER.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: Is it possible to vectorize LineProperties of a plot object?

From: Gustavo Morales

Date: 5 Nov, 2009 01:19:02

Message: 4 of 4

Pekka Kumpulainen and
Steven Lord
 Thank you so much! You make me think that there are truly genius at this newsgroup!
Although, I'm not completely satisfied with the scatter() command. It seems that, in practice, there isn't a direct proportion between size and the area, when you visualize the graph...
For example:
>> X = [0, 3, 2]; Y = [2, -2, 8];
>> ri = [0.1, 0.2, 10]; Ai = pi*ri.^2; Factor = 100;
>> scatter(X,Y,Factor*Ai);

If you, for example, empirically determines that Factor = 100 for small markers (r = 0.1 and 0.2), when you want to plot big markers (r = 10), those markers don't agree with the observed plot

Thank you for your help!
Regards from Venezuela!

Tags for 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