Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: strange error message
Date: Mon, 14 Sep 2009 08:22:02 +0000 (UTC)
Organization: Boeing
Lines: 19
Message-ID: <h8kufa$i02$1@fred.mathworks.com>
References: <ec15a73f-76ad-4291-a568-b615d121e464@v36g2000yqv.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1252916522 18434 172.30.248.35 (14 Sep 2009 08:22:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 14 Sep 2009 08:22:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:570195


stpatryck <stpatryck@gmail.com> wrote in message <ec15a73f-76ad-4291-a568-b615d121e464@v36g2000yqv.googlegroups.com>...
> Hello Folks,
> 
> I typed in these commands:
> >> t=0:0.01:2*pi;s=t;
> >> x=cos(t).*cos(s);y=cos(t).*sin(s);z=sin(t);
> >> surf(x,y,z)
> 
> I got the following error message:
> 
> ??? Error using ==> surf at 78
> Z must be a matrix, not a scalar or vector.
> 
> 
> What am I doing wrong???

Amazingly enough, the error message means exactly what it says! Your x and y inputs to surf form a mesh, and z forms the height at each mesh point. i.e., each combination of an x element and a y element needs to have a z element. So if x is an n-vector and y is an m-vector, then Z needs to be a m-by-n matrix.

James Tursa