필터 지우기
필터 지우기

Surface plot problem,

조회 수: 5 (최근 30일)
james
james 2012년 3월 14일
댓글: Matlabuser 2014년 11월 14일
I'm trying to create a surface plot for an equation,
the code returns the error ??? Error using ==> contourc Contour data must have 2 dimensions
Error in ==> contours at 57 CS=contourc(varargin{numarg_for_call});
Error in ==> contour3 at 87 [c,msg] = contours(args{1:nin});
Error in ==> surfc at 62 [cc,hh] = contour3(cax,x,y,z); %#ok
Error in ==> Untitled4 at 6 surfc(X,Y,Z,C);
Warning: size(CData) must equal size(ZData) or size(ZData)-1 for flat shading
my code is
x = -1:1:1;
y = -1:1:1;
z = -1:1:1;
[X,Y,Z] = meshgrid(x,y,z);
C = (1.10471.*((Z).^2) .* ((X).^2))+(0.0481.*(Y.*Z)*14.*X);
surfc(X,Y,Z,C);
axis([-1 1 -1 1 -1 1]);
Any help would be really appreciated!

채택된 답변

Kevin Holst
Kevin Holst 2012년 3월 14일
You're not feeding the proper inputs into surfc. surfc(x,y,z,c) requires x be a vector of length(n), y a vector of length(m), size(z) = [m,n], and size(c) = size(z). See if this suits your needs:
x = -1:1:1;
y = -1:1:1;
[X,Y] = meshgrid(x,y);
Z = meshgrid(-1:1:1);
C = (1.10471.*((Z).^2) .* ((X).^2))+(0.0481.*(Y.*Z)*14.*X);
surfc(X,Y,Z,C);
axis([-1 1 -1 1 -1 1]);
  댓글 수: 3
Kevin Holst
Kevin Holst 2012년 3월 15일
you'll notice that I actually input a 2d matrix in the code and mentioned a vector in my description. Matrices X and Y can be 2d, Z and C must be 2d, and nothing can be 3d.
Matlabuser
Matlabuser 2014년 11월 14일
Can you please tell me how can I plot my experimental data using surf?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by