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:
Simple how to plot data points

Subject: Simple how to plot data points

From: Philosophaie

Date: 8 May, 2011 13:43:04

Message: 1 of 3

Just a simple problem of graphing data points:

x={70 60 40 20 0 -20 -40 -60 -70}
y={240 155 57 -17 -81 -146 -219 -318 -402}
hold on;
plot(x(:),y(:),'-b')

The error is:

??? Error using ==> plot
Conversion to double from cell is not possible.

Error in ==> xyplot at 4
plot(x(:),y(:),'-b')

Subject: Simple how to plot data points

From: dpb

Date: 8 May, 2011 14:14:02

Message: 2 of 3

On 5/8/2011 8:43 AM, Philosophaie wrote:
> Just a simple problem of graphing data points:
>
> x={70 60 40 20 0 -20 -40 -60 -70}
> y={240 155 57 -17 -81 -146 -219 -318 -402}
> hold on;
> plot(x(:),y(:),'-b')
>
> The error is:
...

Not dereferencing the cell arrays...

plot(x{:},y{:},'-b')

--

Subject: Simple how to plot data points

From: Steven_Lord

Date: 9 May, 2011 00:58:01

Message: 3 of 3



"Philosophaie" <ertlejack@sbcglobal.net> wrote in message
news:iq66l8$867$1@newscl01ah.mathworks.com...
> Just a simple problem of graphing data points:
>
> x={70 60 40 20 0 -20 -40 -60 -70}
> y={240 155 57 -17 -81 -146 -219 -318 -402}
> hold on;
> plot(x(:),y(:),'-b')
>
> The error is:
>
> ??? Error using ==> plot
> Conversion to double from cell is not possible.
>
> Error in ==> xyplot at 4
> plot(x(:),y(:),'-b')

Call PLOT on a vector of data, either by creating it as a vector initially
or by extracting the contents of the cell rather than the cell itself.

x=[70 60 40 20 0 -20 -40 -60 -70];
y=[240 155 57 -17 -81 -146 -219 -318 -402];
hold on;
plot(x, y, '-b')

% or

x={70 60 40 20 0 -20 -40 -60 -70}
y={240 155 57 -17 -81 -146 -219 -318 -402}
hold on;
plot([x{:}], [y{:}],'-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