Error while plotting the surface

조회 수: 2 (최근 30일)
NISHANTH M P
NISHANTH M P 2021년 9월 9일
답변: Mathieu NOE 2021년 9월 9일
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.

답변 (1개)

Mathieu NOE
Mathieu NOE 2021년 9월 9일
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 :

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by