http://www.mathworks.com/matlabcentral/newsreader/view_thread/294393
MATLAB Central Newsreader  Plotting 3d planes
Feed for thread: Plotting 3d planes
enus
©19942014 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Wed, 20 Oct 2010 23:42:04 +0000
Plotting 3d planes
http://www.mathworks.com/matlabcentral/newsreader/view_thread/294393#789325
Ahmed Emad
hi,<br>
I am trying to plot a 3D plane in matlab using the surf command.<br>
I have calculated the plane's equation using 3 points (to be input upon activation of the program). the equation is as follows:<br>
Ps= a + u*L1+ v*L2;<br>
where<br>
[L1]= ba;<br>
& [L2]= cb;<br>
and u and v are varying quantities.<br>
When I try to use the surf command as follows:<br>
surf (Ps, 'DisplayName', 'Ps'); figure(gcf)<br>
i get the following error<br>
Error using ==> surf at 78<br>
Z must be a matrix, not a scalar or vector.<br>
Can someone please tell me what I am doing wrong? <br>
thanks in advance

Thu, 21 Oct 2010 01:21:03 +0000
Re: Plotting 3d planes
http://www.mathworks.com/matlabcentral/newsreader/view_thread/294393#789338
Roger Stafford
"Ahmed Emad" <Ahmedkasrawy@gmail.com> wrote in message <i9nuob$7pi$1@fred.mathworks.com>...<br>
> hi,<br>
> I am trying to plot a 3D plane in matlab using the surf command.<br>
> I have calculated the plane's equation using 3 points (to be input upon activation of the program). the equation is as follows:<br>
> Ps= a + u*L1+ v*L2;<br>
> where<br>
> [L1]= ba;<br>
> & [L2]= cb;<br>
> and u and v are varying quantities.<br>
> When I try to use the surf command as follows:<br>
> surf (Ps, 'DisplayName', 'Ps'); figure(gcf)<br>
> i get the following error<br>
> Error using ==> surf at 78<br>
> Z must be a matrix, not a scalar or vector.<br>
> Can someone please tell me what I am doing wrong? <br>
> thanks in advance<br>
        <br>
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 twodimensiona piece of your plane. That is what the 'meshgrid' function can do for you. It produces matrices rather than vectors. Check it out.<br>
<br>
Roger Stafford