Two minute video shows how to fit a surface to nonuniform data.
Real data is not always on a nice X,Y grid, but the MATLAB commands
SURF and MESH expect them to be. GRIDDATA and MESHGRID help to fix this.
I am very grad to find the program of “advanced-matlab-surface-plot-of-nonuniform-data”, but I could not run it
because of no-coincide of matrix dimension.
Would you please inform me of a mistake I coded (copied).
Best Regards,
————————
%3D graph for nonuniform_data
x=rand(100,1)*16-8;
y=rand(100,1)*16-8;
r=sqrt(x.^2+y.^2)+eps;
z=sin(r)./r;
%
xlin=linspace(min(x),max(x),33);
ylin=linspace(min(y),max(y),33);
[X,Y]=meshgrid(xlin,ylin);
Z=griddata(x,y,z,X,Y,’cubic’);
%
mesh(X,Y,Z); % interpolated
axis tight; hold on
plot3(x,y,z,’.',’MarkerSize’,15)
%%surf(X,Y,Z)
This info about making a surface plot was very usefull for me. In stead of the formule that you used to produce some points, I used 4 XYZ-coordinates that result in an surface in 3D. Is there an easy way to calculate the surface area of this created object?
There is no built in function to do this, but knowing the X,Y,Z of each point in the mesh, you should be able to calculate the area of each four point patch. From there, summing should be easy to know the whole area.
I am not sure that I understand the question. If you have x,y,z triples, you just plot them. Are you trying to fit a polynomial to them? That would imply a two dimensional dataset. Are you trying to fit some kind of a surface to the data?
Dear Sir:
I am very grad to find the program of “advanced-matlab-surface-plot-of-nonuniform-data”, but I could not run it
because of no-coincide of matrix dimension.
Would you please inform me of a mistake I coded (copied).
Best Regards,
————————
%3D graph for nonuniform_data
x=rand(100,1)*16-8;
y=rand(100,1)*16-8;
r=sqrt(x.^2+y.^2)+eps;
z=sin(r)./r;
%
xlin=linspace(min(x),max(x),33);
ylin=linspace(min(y),max(y),33);
[X,Y]=meshgrid(xlin,ylin);
Z=griddata(x,y,z,X,Y,’cubic’);
%
mesh(X,Y,Z); % interpolated
axis tight; hold on
plot3(x,y,z,’.',’MarkerSize’,15)
%%surf(X,Y,Z)
I copied the code from you message and it worked perfectly on my side! - sorry!
The code you pasted here worked exactly right for me too. I am not sure what to do for you.
Sorry,
Doug
Greg pointed me to this solution he wrote a while back that might be of interest also:
Tech Note 1212 - Using MESHGRID and GRIDDATA to Fit Vector Data and Plot Unevenly Spaced Data http://www.mathworks.com/support/tech-notes/1200/1212.html
Dear Doug,
This info about making a surface plot was very usefull for me. In stead of the formule that you used to produce some points, I used 4 XYZ-coordinates that result in an surface in 3D. Is there an easy way to calculate the surface area of this created object?
Best regards,
Els
Els,
There is no built in function to do this, but knowing the X,Y,Z of each point in the mesh, you should be able to calculate the area of each four point patch. From there, summing should be easy to know the whole area.
Doug
I have three column data (time,height,collection) supposedly x,y,z data. I want to plot it and get the equation. How can I do that with Matlab.
eg data:
x - y - z
1 - 1 - 130
2 - 1 - 130
3 - 1 - 130
4 - 1 - 130
7 - 2 - 130
10 - 2 - 130
16 - 2 - 130
25 - 2 - 130
40 - 2 - 130
63 - 3 - 130
100 - 3 - 130
160 - 3 - 130
250 - 3 - 130
300 - 3 - 130
400 - 3 - 130
500 - 3 - 130
1 - 3 - 260
2 - 3 - 260
3 - 3 - 260
4 - 3 - 260
7 - 3 - 260
10 - 3 - 260
16 - 4 - 260
25 - 4 - 260
40 - 4 - 260
63 - 6 - 260
100 - 8 - 260
160 - 10 - 260
250 - 11 - 260
300 - 11 - 260
400 - 11 - 260
500 - 11 - 260
1 - 4 - 390
2 - 5 - 390
3 - 5 - 390
4 - 5 - 390
7 - 6 - 390
10 - 7 - 390
16 - 8 - 390
25 - 10 - 390
40 - 12 - 390
63 - 14 - 390
100 - 15 - 390
160 - 19 - 390
250 - 22 - 390
300 - 26 - 390
400 - 30 - 390
500 - 30 - 390
1 - 4 - 650
2 - 5 - 650
3 - 5 - 650
4 - 5 - 650
7 - 5 - 650
10 - 7 - 650
16 - 8 - 650
25 - 9 - 650
40 - 12 - 650
63 - 14 - 650
100 - 18 - 650
160 - 22 - 650
250 - 27 - 650
300 - 27 - 650
400 - 36 - 650
500 - 40 - 650
1 - 2 - 910
2 - 2 - 910
3 - 2 - 910
4 - 3 - 910
7 - 5 - 910
10 - 5 - 910
16 - 7 - 910
25 - 9 - 910
40 - 15 - 910
63 - 20 - 910
100 - 24 - 910
160 - 32 - 910
250 - 38 - 910
300 - 41 - 910
400 - 46 - 910
500 - 49 - 910
I have multiple [x,y,z] matrices of my data with which i want to plot the surface using a 7th order polynomial, how can I do that??
Venkat,
I am not sure that I understand the question. If you have x,y,z triples, you just plot them. Are you trying to fit a polynomial to them? That would imply a two dimensional dataset. Are you trying to fit some kind of a surface to the data?
You might be best off looking here:
http://blogs.mathworks.com/pick/how-to-get-help/
It shows how to ask for help at the bottom.
Doug