Got Questions? Get Answers.
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:
Plotting 3d planes

Subject: Plotting 3d planes

From: Ahmed Emad

Date: 20 Oct, 2010 23:42:04

Message: 1 of 2

hi,
I am trying to plot a 3D plane in matlab using the surf command.
I have calculated the plane's equation using 3 points (to be input upon activation of the program). the equation is as follows:
                 Ps= a + u*L1+ v*L2;
where
                 [L1]= b-a;
            & [L2]= c-b;
and u and v are varying quantities.
When I try to use the surf command as follows:
                  surf (Ps, 'DisplayName', 'Ps'); figure(gcf)
i get the following error
                 Error using ==> surf at 78
                 Z must be a matrix, not a scalar or vector.
Can someone please tell me what I am doing wrong?
thanks in advance

Subject: Plotting 3d planes

From: Roger Stafford

Date: 21 Oct, 2010 01:21:03

Message: 2 of 2

"Ahmed Emad" <Ahmedkasrawy@gmail.com> wrote in message <i9nuob$7pi$1@fred.mathworks.com>...
> hi,
> I am trying to plot a 3D plane in matlab using the surf command.
> I have calculated the plane's equation using 3 points (to be input upon activation of the program). the equation is as follows:
> Ps= a + u*L1+ v*L2;
> where
> [L1]= b-a;
> & [L2]= c-b;
> and u and v are varying quantities.
> When I try to use the surf command as follows:
> surf (Ps, 'DisplayName', 'Ps'); figure(gcf)
> i get the following error
> Error using ==> surf at 78
> Z must be a matrix, not a scalar or vector.
> Can someone please tell me what I am doing wrong?
> thanks in advance
- - - - - - - - -
  You haven't said how you handled the 'u' and 'v' parameters. Based on the error message you received I would guess that you let each one be a vector. That wouldn't work. It would correspond to traveling along some straight line on your plane. You want 'u' and 'v' to vary independently so you cover a two-dimensiona piece of your plane. That is what the 'meshgrid' function can do for you. It produces matrices rather than vectors. Check it out.

Roger Stafford

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