Path: news.mathworks.com!not-for-mail
From: "Yehonatan " <math8yehonatan@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to rotate a 2D plot around an axis to create a 3D plot?
Date: Sun, 21 Apr 2013 20:19:12 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 50
Message-ID: <kl1hjv$dah$1@newscl01ah.mathworks.com>
References: <kkkri4$lvo$1@newscl01ah.mathworks.com>
Reply-To: "Yehonatan " <math8yehonatan@gmail.com>
NNTP-Posting-Host: www-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1366575552 13649 172.30.248.48 (21 Apr 2013 20:19:12 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 21 Apr 2013 20:19:12 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 4226123
Xref: news.mathworks.com comp.soft-sys.matlab:794023

Hi anthony,
Download gridfit from the matlab exchange and use this code:


clear

x = linspace(-3,3,100);
y = linspace(-3,3,100);
g = 1 - exp(-(x.^2));

f = 1 - exp(-(x.^2));
X = x;
Y(1,1:100) = x(1,50);
X(1,101:200) = x(1,50);
Y(1,101:200) = x;
Z(1,1:100) = f
Z(1,101:200) = f

for ind = 1:100
     X(1,(200 + ind)) = x(1,ind);
     Y(1,(200 + ind)) = x(1,ind);
     
end

Z(1,201:300) = f;

ind = 1;
indx = 1;
indy = 100;

while(ind <= 100)
    X(1,(300 + ind)) = x(1,indx);
    Y(1,(300 + ind)) = y(1,indy);
   
    
    ind = ind + 1;
    indx = indx + 1;
    indy = indy - 1;
end
 
Z(1,301:400) = f;

X = X';
Y = Y';
Z = Z';
figure

zgrid = gridfit(X,Y,Z,x,x);

surf(x,x,zgrid);