Difference in TriSurf and Surf - Adding Two trisurf plot on one graph.

I uses this to get a surface plot between three variables. My data was in one column.
trisurf(tri,x,y,z)
But when I use Surf(x,y,z) it gives error "??? Undefined function or variable 'X'."
Also I have 10 sets of data how can I plot more than one surface on one graph in a different color.

Respuestas (1)

Walter Roberson
Walter Roberson el 9 de Dic. de 2012
Note that MATLAB is case-sensitive, so if you defined a variable "x" then "X" is a different variable. Also, Surf() would be different than surf()
Please show your exact code.
To plot multiple surfaces, use "hold on" after the first plot. You can pass color information to surf()

3 comentarios

Thanks I understand the "hold on" and color part but Now when I use the surf (x,y,z) it gives this error.
??? Error using ==> surf at 78 Z must be a matrix, not a scalar or vector.
Why do I need a Matrix and how should I change my single row data of x,y,z to use to plot a surface!
Also can you tell me who do define data of x variable from excel file column A1 to Z1 ; y is B2 to Z2 and z is C3 to Z3.
I have this code so far
if true
% code
holdState = ishold;
tri = delaunay(x1,y1);
h1 = trisurf(tri, x1, y1, z1)
set(h1, 'FaceColor', 'g')
hold on;
h2 = trisurf(tri, x2, y2, z2)
set(h2, 'FaceColor', 'b')
if ~holdState,
hold off;
end
colormap(cmap);
if nargout,
h = [h1 h2];
end
surf() is simply not designed to handle vectors of X, Y, Z. It is designed for working on grids of data.
It is not clear to me why you are looking to use surf() when you are already using trisurf() ? If there is a good reason to use surf() instead, then see TriScatteredInterp
indata = xlsread('YourFileName.xls');
x = indata(1:26, 1);
y = indata(2:27, 2);
z = indata(3:28, 3);
contour() requires grids of data too. You need exactly the same preparation work for contour() that you need for surf()

Iniciar sesión para comentar.

Preguntada:

Afz
el 9 de Dic. de 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by