http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290
MATLAB Central Newsreader  using mesh to make 3D plot
Feed for thread: using mesh to make 3D plot
enus
©19942015 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

Tue, 08 Sep 2009 10:00:23 +0000
using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#678684
Windell
Hi,<br>
<br>
I'm attempting to plot a 3D radiation pattern of an antenna that I tested. I stored all the power levels at different azimuths and elevations in a txt file. I convert my results to rectangular coordinates using the sph2cart function and I attempt to mesh the data to create a 3D plot. In doing so I received an error: "Warning: Z must not be a scalar or vector, not rendering surface." I'm new to plotting in 3D in matlab so I'm not sure what I should do from here. I would greatly appreciate your help!<br>
<br>
Thanks for your time!<br>
Windell<br>
<br>
%load & store the signal angle of attack values.<br>
load monopole3D.txt<br>
theta = monopole3D(:,1);<br>
phi=monopole3D(:,2);<br>
r=monopole3D(:,3);<br>
%convert to radians.<br>
theta=(pi/180)*theta;<br>
phi=(pi/180)*phi;<br>
%make the radius not negative.<br>
r=r+40;<br>
%convert spherical coordinates to rectangular coordinates.<br>
[X Y Z]=sph2cart(theta,phi,r);<br>
figure;<br>
%plot in 3D<br>
mesh(X,Y,Z)

Tue, 08 Sep 2009 12:38:02 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#678714
Wayne King
"Windell " <windelljones@gmail.com> wrote in message <h859vn$802$1@fred.mathworks.com>...<br>
> Hi,<br>
> <br>
> I'm attempting to plot a 3D radiation pattern of an antenna that I tested. I stored all the power levels at different azimuths and elevations in a txt file. I convert my results to rectangular coordinates using the sph2cart function and I attempt to mesh the data to create a 3D plot. In doing so I received an error: "Warning: Z must not be a scalar or vector, not rendering surface." I'm new to plotting in 3D in matlab so I'm not sure what I should do from here. I would greatly appreciate your help!<br>
> <br>
> Thanks for your time!<br>
> Windell<br>
> <br>
> %load & store the signal angle of attack values.<br>
> load monopole3D.txt<br>
> theta = monopole3D(:,1);<br>
> phi=monopole3D(:,2);<br>
> r=monopole3D(:,3);<br>
> %convert to radians.<br>
> theta=(pi/180)*theta;<br>
> phi=(pi/180)*phi;<br>
> %make the radius not negative.<br>
> r=r+40;<br>
> %convert spherical coordinates to rectangular coordinates.<br>
> [X Y Z]=sph2cart(theta,phi,r);<br>
> figure;<br>
> %plot in 3D<br>
> mesh(X,Y,Z)<br>
Hi Windell, mesh() is expecting that at least your Z argument is a matrix. I would suggest using meshgrid(). <br>
<br>
>>doc meshgrid<br>
<br>
to convert your X,Y,Z outputs to matrices amenable to calling mesh().<br>
<br>
Hope that helps,<br>
wayne

Wed, 09 Sep 2009 00:27:01 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#678872
Windell
Thanks for your reply Wayne! Just tried what you suggested and I'm still receiving an error. Here is my code.<br>
<br>
%load & store the signal angle of attack values.<br>
load monopole3D.txt<br>
theta = monopole3D(:,1);<br>
phi=monopole3D(:,2);<br>
r=monopole3D(:,3);<br>
<br>
%convert to radians.<br>
theta=(pi/180)*theta;<br>
phi=(pi/180)*phi;<br>
<br>
%make the radius not negative.<br>
r=r+40;<br>
<br>
%convert spherical coordinates to rectangular coordinates.<br>
[x,y,z]=sph2cart(theta,phi,r);<br>
[X,Y,Z]=meshgrid(x,y,z);<br>
<br>
%plot in 3D<br>
mesh(X,Y,Z)<br>
<br>
The error I'm getting is the following: "Error in ==> meshgrid at 62<br>
zz = zz(ones(ny,1),ones(nx,1),:); Error in ==> v2_plot at 123<br>
[X,Y,Z]=meshgrid(x,y,z);"<br>
<br>
Much Appreciated<br>
Windell<br>
<br>
"Wayne King" <wmkingty@gmail.com> wrote in message <h85j7a$dkh$1@fred.mathworks.com>...<br>
> "Windell " <windelljones@gmail.com> wrote in message <h859vn$802$1@fred.mathworks.com>...<br>
> > Hi,<br>
> > <br>
> > I'm attempting to plot a 3D radiation pattern of an antenna that I tested. I stored all the power levels at different azimuths and elevations in a txt file. I convert my results to rectangular coordinates using the sph2cart function and I attempt to mesh the data to create a 3D plot. In doing so I received an error: "Warning: Z must not be a scalar or vector, not rendering surface." I'm new to plotting in 3D in matlab so I'm not sure what I should do from here. I would greatly appreciate your help!<br>
> > <br>
> > Thanks for your time!<br>
> > Windell<br>
> > <br>
> > %load & store the signal angle of attack values.<br>
> > load monopole3D.txt<br>
> > theta = monopole3D(:,1);<br>
> > phi=monopole3D(:,2);<br>
> > r=monopole3D(:,3);<br>
> > %convert to radians.<br>
> > theta=(pi/180)*theta;<br>
> > phi=(pi/180)*phi;<br>
> > %make the radius not negative.<br>
> > r=r+40;<br>
> > %convert spherical coordinates to rectangular coordinates.<br>
> > [X Y Z]=sph2cart(theta,phi,r);<br>
> > figure;<br>
> > %plot in 3D<br>
> > mesh(X,Y,Z)<br>
> Hi Windell, mesh() is expecting that at least your Z argument is a matrix. I would suggest using meshgrid(). <br>
> <br>
> >>doc meshgrid<br>
> <br>
> to convert your X,Y,Z outputs to matrices amenable to calling mesh().<br>
> <br>
> Hope that helps,<br>
> wayne

Thu, 12 Aug 2010 15:48:24 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#770885
Christopher Rouxel
This GUI might help you:<br>
<a href="http://www.mathworks.com/matlabcentral/fileexchange/281773dperformancemapgui">http://www.mathworks.com/matlabcentral/fileexchange/281773dperformancemapgui</a>

Wed, 24 Apr 2013 10:29:10 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903080
christian
"Windell " <windelljones@gmail.com> wrote in message <h86sol$1h9$1@fred.mathworks.com>...<br>
> Thanks for your reply Wayne! Just tried what you suggested and I'm still receiving an error. Here is my code.<br>
> <br>
> %load & store the signal angle of attack values.<br>
> load monopole3D.txt<br>
> theta = monopole3D(:,1);<br>
> phi=monopole3D(:,2);<br>
> r=monopole3D(:,3);<br>
> <br>
> %convert to radians.<br>
> theta=(pi/180)*theta;<br>
> phi=(pi/180)*phi;<br>
> <br>
> %make the radius not negative.<br>
> r=r+40;<br>
> <br>
> %convert spherical coordinates to rectangular coordinates.<br>
> [x,y,z]=sph2cart(theta,phi,r);<br>
> [X,Y,Z]=meshgrid(x,y,z);<br>
> <br>
> %plot in 3D<br>
> mesh(X,Y,Z)<br>
> <br>
> The error I'm getting is the following: "Error in ==> meshgrid at 62<br>
> zz = zz(ones(ny,1),ones(nx,1),:); Error in ==> v2_plot at 123<br>
> [X,Y,Z]=meshgrid(x,y,z);"<br>
> <br>
> Much Appreciated<br>
> Windell<br>
> <br>
> "Wayne King" <wmkingty@gmail.com> wrote in message <h85j7a$dkh$1@fred.mathworks.com>...<br>
> > "Windell " <windelljones@gmail.com> wrote in message <h859vn$802$1@fred.mathworks.com>...<br>
> > > Hi,<br>
> > > <br>
> > > I'm attempting to plot a 3D radiation pattern of an antenna that I tested. I stored all the power levels at different azimuths and elevations in a txt file. I convert my results to rectangular coordinates using the sph2cart function and I attempt to mesh the data to create a 3D plot. In doing so I received an error: "Warning: Z must not be a scalar or vector, not rendering surface." I'm new to plotting in 3D in matlab so I'm not sure what I should do from here. I would greatly appreciate your help!<br>
> > > <br>
> > > Thanks for your time!<br>
> > > Windell<br>
> > > <br>
> > > %load & store the signal angle of attack values.<br>
> > > load monopole3D.txt<br>
> > > theta = monopole3D(:,1);<br>
> > > phi=monopole3D(:,2);<br>
> > > r=monopole3D(:,3);<br>
> > > %convert to radians.<br>
> > > theta=(pi/180)*theta;<br>
> > > phi=(pi/180)*phi;<br>
> > > %make the radius not negative.<br>
> > > r=r+40;<br>
> > > %convert spherical coordinates to rectangular coordinates.<br>
> > > [X Y Z]=sph2cart(theta,phi,r);<br>
> > > figure;<br>
> > > %plot in 3D<br>
> > > mesh(X,Y,Z)<br>
> > Hi Windell, mesh() is expecting that at least your Z argument is a matrix. I would suggest using meshgrid(). <br>
> > <br>
> > >>doc meshgrid<br>
> > <br>
> > to convert your X,Y,Z outputs to matrices amenable to calling mesh().<br>
> > <br>
> > Hope that helps,<br>
> > wayne<br>
<br>
<br>
Hi windell<br>
i have the same issue. have you find any solution?<br>
best regards<br>
Christian

Thu, 25 Apr 2013 18:58:08 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903220
Yehonatan
Hi christian,<br>
Explain the problom to me with code, May be i can help you....

Sun, 28 Apr 2013 01:49:09 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903314
christian
"Yehonatan " <math8yehonatan@gmail.com> wrote in message <klbuc0$4bf$1@newscl01ah.mathworks.com>...<br>
> Hi christian,<br>
> Explain the problom to me with code, May be i can help you....<br>
<br>
<br>
Hi yehonatan<br>
thanks for your interest<br>
this is my code<br>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""<br>
theta=[0 pi/2 pi/2 0.554 5.729 5.729 0.554 0.554 5.729 5.729 0.554 1.206 5.077 5.077 1.206];<br>
phi=[0 0 pi/2 0.314 0.314 0.314 0.314 0.942 0.942 0.942 0.942 0.524 0.524 0.524 0.524];<br>
r=[0.01 0.01 0.01 0.0334 0.0334 0.0334 0.0334 0.0273 0.0273 0.0273 0.0273 0.0351 0.0351 0.0351 0.0351];<br>
[theta,phi,r]=meshgrid(theta,phi,r);<br>
[x,y,z]=sph2cart(theta,phi,r);<br>
surf(x,y,z)<br>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""<br>
may be the data are not good. But i just want to now how to plot a 3D surface with a data list like this<br>
best regards

Sun, 28 Apr 2013 06:17:11 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903320
Yehonatan
OK Christian,<br>
From what i understand you don't have any experience with matlab. I see here you have a list of data, i guess you created some where else. I have to know if this data can be created by a math function. In other words, can you create your data list by this kind of code:<br>
x = 1:50;<br>
y = 1:50;<br>
z = sin(x) + cos(y);<br>
<br>
the reason I'm asking you is because there are no fast learning solution for this problem. It's not a big problem but its not a small one either. I want you to tell me exactly what do you want to do and how much learning you want to invest.<br>
<br>
Need To Know:<br>
What are your x,y,z<br>
what kind of 3d plot: surface, contour, curve<br>
can you create the data list by a function like the above code<br>
how much you want to invest in matlab experience<br>
<br>
Best Regards

Sun, 28 Apr 2013 14:13:11 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903336
christian
hi yehonatan<br>
Indeed i have any experience with matlab plotting. And i am willing to learn more about it.<br>
the data list especially for the "r" vector are obtained by a numerical simulation.<br>
the "r'' vector is associated to the [theta,phi] direction<br>
and [x,y,z] is the representation in cartesian coordinates of the curve i want to plot to define the variation of "r" in the all space.<br>
<br>
thanks for your help<br>
best regards

Sun, 28 Apr 2013 15:23:10 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903343
Yehonatan
OK Christian, Lets start...<br>
The 3d plot field in matlab is a big one, therefore we don't intend to learn all of it, just the one we need. From what i can tell you want a 3d curve plot. We do not need to use meshgrid for that matter nor we need to learn how. Meshgrid is used for a surface or mesh plots, not a curve one. In light of this, what we need is simply three vectors of data for each x,y and z dimensions. Just create three vectors like theta,phi and r, then use plot3 in order to plot them.<br>
If that does not suit you, next time specify the type of plot you want and explain to me with minimum of detail as you can how to create the data you want to plot without using the 3d plot tools like meshgrid you used earlier.

Sun, 28 Apr 2013 16:49:09 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903345
christian
hi yehonatan<br>
https://www.dropbox.com/s/t62do1b3zkdk0bf/3d%20distribution.png<br>
the link above is the picture of the result of plotting i want to carry out.<br>
the threes vectors list I send before are the only data in my possesion.<br>
theta and phi represent the spherical coordinates of 15 points for 15 directions take on a unit sphere.<br>
and "r" represent a value linked to those points and obtained by a numerical simulation in micromechanics modelling. there is no way to create by another way other point without 3d plot.<br>
thanks for help<br>
best regards

Sun, 28 Apr 2013 18:32:09 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903349
Yehonatan
This is a biggy....<br>
Christian, you are aiming for a shape surface. It's not impossible but it is not easy either.<br>
In order to create a shape like surface in matlab you have to understand the basics of surface plot function. Before we continue I must inform you that the task ahead might take some time to achieve. For starters, let’s try to understand how surf function works. If we will give the surf function three matrices for x,y and z this is what it will do:<br>
<br>
Here we have three matrices I created for the surf function (no need to understand how I did it and why for now):<br>
<br>
x =<br>
<br>
1 2 3 4 5<br>
1 2 3 4 5<br>
1 2 3 4 5<br>
1 2 3 4 5<br>
1 2 3 4 5<br>
<br>
<br>
y =<br>
<br>
1 1 1 1 1<br>
2 2 2 2 2<br>
3 3 3 3 3<br>
4 4 4 4 4<br>
5 5 5 5 5<br>
<br>
<br>
z =<br>
<br>
2.0000 5.0000 10.0000 17.0000 26.0000<br>
1.5000 4.5000 9.5000 16.5000 25.5000<br>
1.3333 4.3333 9.3333 16.3333 25.3333<br>
1.2500 4.2500 9.2500 16.2500 25.2500<br>
1.2000 4.2000 9.2000 16.2000 25.2000<br>
<br>
<br>
the surf function will look at all the combinations of 4 data points that are close together. For instance: [(1,1),(1,2),(2,1),(2,2)] ,[3,3),(3,4),(4,3),(4,4)] and <br>
[(1,2),(1,3),(2,2),(2,3)]. Each parentheses represent a correspond cell in all the matrices, in other words it represent a data point that consist of three dimensions. Each bracket is an example of four data points that the surf function uses in the creation of the 3d plot. The surf function takes all of the combinations of four data points like I showed above and create out of each one a 3d surface square. So, in order to use surf function properly we need not only to give the surf function data points but also we need to organize the data points in the matrices we intend to give the surf function in such a way that all of the four points combinations in the matrices will be a 3d square we want to be displayed in the result 3d plot. <br>
<br>
Here is a video I created that shows the inner working of the surf function.:<br>
<a href="http://www.youtube.com/watch?v=poUTVYqu_Z4&feature=youtu.be">http://www.youtube.com/watch?v=poUTVYqu_Z4&feature=youtu.be</a><br>
<br>
Christian, this is the first step. When we understand it we will move to the next. Now,<br>
If you don’t understand something here ask, if it’s too much for you try another program but this is how it is done in matlab as far as I know. <br>
I’ll be gladly continue teaching you, it’s your call.<br>
<br>
Best regards.

Sun, 28 Apr 2013 21:55:09 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903359
christian
hi yehonathan<br>
gratitude for your time.<br>
in the bracket why four data points instead of three?

Sun, 28 Apr 2013 23:17:09 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903362
Yehonatan
Because the surf function creates 3d squares and not 3d triangles. Every surface part the surf function creates is a 3d square, therefore it need 4 data points. If you saw the youtube video, you can see that in the bottom of the sphere shape it looks like the surf function creates triangles but in fact its a square that have a twin data point.<br>
If you ask why it is done that way i don't know, this is how the surf function programmers implemented the surf function.

Sun, 28 Apr 2013 23:42:12 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903365
Yehonatan
For further understanding, In the YouTube video I created the sphere x,y and z matrices using the matlab sphere function. In the first section I plotted the data point that I created using the plot3 function. In the second section I took every four combination of data points and told the surf function to plot. With that said, you can see how all of the combinations combined create the result sphere surface.

Sun, 28 Apr 2013 23:54:10 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903366
christian
about combination how are you define the order?

Mon, 29 Apr 2013 00:03:09 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903368
christian
and also in the example you posted [(1,1),(1,2).......] represent the lines and rows of all the matrix (x,y,z) or just the matrix Z ?

Mon, 29 Apr 2013 00:52:09 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903371
christian
hi yehonatan<br>
i finally understand about the four datas and the different couple (i,j). i still confuse about the order of all the combination

Mon, 29 Apr 2013 01:30:10 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903372
Yehonatan
Ok...<br>
For the second question, Yes... It defines the rows and columns of all the three matrices. <br>
(1,2) is the cell in x,y and z matrices in the location of row 1 and column 2. <br>
<br>
For the first question, it doesn't matter how the surf function goes over the combinations.<br>
Think of it like this, the surf function does not create one surface. Instead it creates a lot of individual’s surfaces. What are these individuals’ surfaces is determined by every combination of four data points that are close together. So, you can go over the combinations in any way you like as long as you use each one of them. <br>
<br>
If you look at the YouTube video you can see how I was able to play with the surf function. I went over the individuals surfaces in tow different ways. As long as you organize the matrices so that each four data points represents an individual surface you wish to plot you'll be able to plot anything you want.

Mon, 29 Apr 2013 02:32:09 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903374
Yehonatan
So,<br>
If you can figure out what are yours individuals surfaces you can use surf to plot them in tow general ways:<br>
1) If you can combine all of the individual’s surfaces in to one x,y and z matrices then do it.<br>
2) If you can't combine all of the individual’s surfaces you can plot them one at a time like I did in the YouTube video.<br>
<br>
remember that each individual surface has four data point, each data point consist of three data point for each of the x,y and z dimensions.<br>
<br>
The act of creating a single matrix for each of the three dimensions is not an easy one when dealing with shapes like surface you showed me earlier. The problem lies in the fact that each individual surface uses the same data points as the individual’s surfaces next to it. So, it’s quite a difficult organizing task.

Mon, 29 Apr 2013 13:04:07 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903393
christian
Hi yehonatan<br>
What is the surf syntax to plot each individual square?

Mon, 29 Apr 2013 13:49:09 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903399
Yehonatan
Let's see now an example...<br>
If I want to plot this 3d squares:<br>
<br>
Square 1:<br>
<br>
x1 =<br>
<br>
1 2 <br>
1 2 <br>
<br>
<br>
<br>
y1 =<br>
<br>
1 1 <br>
2 2 <br>
<br>
<br>
z1 =<br>
<br>
1 4 <br>
1 4 <br>
<br>
<br>
Square 2:<br>
<br>
x2 =<br>
<br>
2 3<br>
2 3<br>
<br>
<br>
<br>
y2 =<br>
<br>
1 1<br>
2 2<br>
<br>
<br>
<br>
z2 =<br>
<br>
4 9<br>
4 9<br>
<br>
<br>
Square 3: <br>
<br>
x3 =<br>
<br>
<br>
1 2 <br>
1 2 <br>
<br>
<br>
y3 =<br>
<br>
<br>
2 2 <br>
3 3 <br>
<br>
<br>
z3 =<br>
<br>
<br>
1 4 <br>
1 4 <br>
<br>
Square 4:<br>
<br>
x4 =<br>
<br>
<br>
2 3<br>
2 3<br>
<br>
<br>
y4 =<br>
<br>
<br>
2 2<br>
3 3<br>
<br>
<br>
z4 =<br>
<br>
<br>
4 9<br>
4 9 <br>
<br>
<br>
I can plot all of these individuals’ squares like this:<br>
<br>
figure(1) % Open a figure window<br>
<br>
hold on % everything I plot will be saved and will not be erased by new plot command<br>
<br>
surf(x1,y1,z1);<br>
surf(x2,y2,z2);<br>
surf(x3,y3,z3);<br>
surf(x4,y4,z4);<br>
<br>
Another way to plot all of this individuals squares is by creating one matrix for x,y and z that will contain all of the squares:<br>
<br>
x5 =<br>
<br>
1 2 3<br>
1 2 3<br>
1 2 3<br>
<br>
<br>
y5 =<br>
<br>
1 1 1<br>
2 2 2<br>
3 3 3<br>
<br>
<br>
z5 =<br>
<br>
1 4 9<br>
1 4 9<br>
1 4 9<br>
<br>
Go over all the four points combinations and see for yourself how we have in this matrices all of the individuals squares we plotted earlier. This is plotted in the same way as before. Let’s create another figure and compare the two ways:<br>
<br>
figure(2) % open another figure window<br>
<br>
surf(x5,y5,z5);<br>
<br>
Use the rotate button the check the tow surfaces and see for yourself that there are alike.

Mon, 29 Apr 2013 14:24:10 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903404
christian
thanks i understand clearly this part<br>
now for my issue (plot a shape surface in the same way like the picture i send in the link) can you check this code<br>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""<br>
theta=[0 pi/2 pi/2 0.554 5.729 5.729 0.554 0.554 5.729 5.729 0.554 1.206 5.077 5.077 1.206];<br>
phi=[0 0 pi/2 0.314 0.314 0.314 0.314 0.942 0.942 0.942 0.942 0.524 0.524 0.524 0.524];<br>
t=[0.01 0.01 0.01 0.0334 0.0334 0.0334 0.0334 0.0273 0.0273 0.0273 0.0273 0.0351 0.0351 0.0351 0.0351];<br>
[theta,phi]=meshgrid(theta,phi);<br>
r=diag(t);<br>
[x,y,z]=sph2cart(theta,phi,r)<br>
surf(x,y,z)<br>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""<br>
it seems like i have one part of the surface but may be i need to create by interpolation more point to have a refined mesh. what's your point?

Mon, 29 Apr 2013 15:19:09 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903406
Yehonatan
Ummmmm......<br>
<br>
Before we continue you must be sure you understand everything I said, if not ask again.<br>
<br>
Now, its better we talk on email because I need to show you some pictures to explain the new stuff. For now, I used the code you sent me to show me the data points your code generated. It seems you don't have enough data to create the plot you showed me, furthermore, I looked at the theta,phi,t data points and then looked at the x,y,z data points. The x,y,z data points are useless (they can’t create any useful surface), for the theta,phi,t data points I choose which is x,y and z arbitrary and then I plotted the data points. It seemed that the theta, phi, t data points are capable of creating a useful surface but there is not enough data to do so.<br>
<br>
I don’t understand the background of you data points. It’s not a good idea to explain me the background either. Instead try to ask me matlab regarding questions.<br>
You need to aim towards this: Don’t think of plotting a function, instead think of plotting data points. If, for example you didn’t have a computer what would you do? Youll’d be creating the data points, then you would draw them on paper and you would connect the data points so that they will create the shape you want. Therefore, try to give me data points with x,y and z coordinates. <br>
<br>
When we will have the data points then I will help with the organizing task. I can’t do the math for you, I can help you implement your math in matlab.<br>
Best Regards….

Mon, 29 Apr 2013 17:54:10 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903414
christian
hi yehonatan <br>
i send you a mail for asking about pictures. i hope you receive it

Mon, 29 Apr 2013 17:57:49 +0000
Re: using mesh to make 3D plot
http://www.mathworks.com/matlabcentral/newsreader/view_thread/260290#903415
Steven_Lord
<br>
<br>
"Yehonatan " <math8yehonatan@gmail.com> wrote in message <br>
news:klkall$lks$1@newscl01ah.mathworks.com...<br>
> Because the surf function creates 3d squares and not 3d triangles. Every <br>
> surface part the surf function creates is a 3d square, therefore it need 4 <br>
> data points. If you saw the youtube video, you can see that in the bottom <br>
> of the sphere shape it looks like the surf function creates triangles but <br>
> in fact its a square that have a twin data point.<br>
> If you ask why it is done that way i don't know, this is how the surf <br>
> function programmers implemented the surf function.<br>
<br>
FYI if you want to create a surface plot whose faces are triangles, look at <br>
the TRISURF function.<br>
<br>
<a href="http://www.mathworks.com/help/matlab/ref/trisurf.html">http://www.mathworks.com/help/matlab/ref/trisurf.html</a><br>
<br>
 <br>
Steve Lord<br>
slord@mathworks.com<br>
To contact Technical Support use the Contact Us link on <br>
<a href="http://www.mathworks.com">http://www.mathworks.com</a>