Borrar filtros
Borrar filtros

Create 3D Surf from table of data

8 visualizaciones (últimos 30 días)
Camila Gill
Camila Gill el 13 de Abr. de 2020
Respondida: Star Strider el 13 de Abr. de 2020
Given data attached:
I am trying to create a 3D plot using 'surf' command. Here is my own attempt at the code:
x = trainingdata(:,1);
y = trainingdata(:,2);
[X,Y] = meshgrid(x,y);
z = trainingdata(:,3);
figure(1)
surf(X,Y,z);
Need matrices that are at least 18x18 in size.
I am having trouble with the 'z' term. I am not able to plot it because I don't understand how to format the 'z' matrix. This is the error message shown:
Error using surf (line 71)
Z must be a matrix, not a scalar or vector
Error in fdm_nn_CGill (line 65)
surf(X,Y,z);

Respuestas (1)

Star Strider
Star Strider el 13 de Abr. de 2020
The data are gridded, so you simply need to use the reshape function to create matrices from them:
[~,ix] = unique(trainingdata(:,1));
rc = mean(diff(ix));
X = reshape(trainingdata(:,1),rc,[]);
Y = reshape(trainingdata(:,2),rc,[]);
Z = reshape(trainingdata(:,3),rc,[]);
figure
surf(layerthick, speed, Z)
grid on
xlabel('Layer Thickness')
ylabel('Speed')
zlabel('Dependent Variable')
view(50,30)
.

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by