![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/733689/image.png)
Error while plotting the surface
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
x = 0:0.1:100;
y = 0:0.1:100;
z= 6*(x.*x)+ y + (3*x) + 5*(x.*y)+10;
surf(x,y,z);
my error:Z must be a matrix, not a scalar or vector.
0 Kommentare
Antworten (1)
Mathieu NOE
am 9 Sep. 2021
hello
you need to create a grid from the 1D array x and y . This is done via meshgrid
code :
clc
clearvars
x = 0:1:100;
y = 0:1:100;
[xx,yy] = meshgrid(x,y) ;
z= 6*(xx.*xx)+ yy + (3*xx) + 5*(xx.*yy)+10;
surf(xx,yy,z);
cmap = jet(256);
colormap(cmap)
colorbar('vert')
plot :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/733689/image.png)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!