Path: news.mathworks.com!not-for-mail
From: "David Doria" <daviddoria@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: inverse of meshgrid?
Date: Sun, 5 Oct 2008 17:56:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 20
Message-ID: <gcav3h$5fl$1@fred.mathworks.com>
Reply-To: "David Doria" <daviddoria@gmail.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1223229361 5621 172.30.248.37 (5 Oct 2008 17:56:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 5 Oct 2008 17:56:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1105197
Xref: news.mathworks.com comp.soft-sys.matlab:493718


some functions, like sphere(), return data that is ready for plotting with something like mesh or surf. If I am interested in plotting the points returned by a function like this, I have done

[X Y Z] = sphere;
n = 21;
counter = 0;
for i = 1:n
    for j = 1:n
        counter = counter + 1;
        x(counter) = X(i,j);
        y(counter) = Y(i,j);
        z(counter) = Z(i,j);
    end
end

plot3(x, y, z, 'o')

Is there a better way to do this?

Thanks,
Dave