How do I plot 3d graphs using just matrices Values

조회 수: 9 (최근 30일)
allbert
allbert 2018년 4월 25일
댓글: allbert 2018년 4월 25일
A = {1;2;5;7;10;20};
B = {1;2;5;7;10;20}';
[X Y] = meshgrid(A,B);
Z = { 1 8 18 21 25 26; 1 8 18 21 25 26; 1 8 18 21 25 26; 1 8 18 21 25 26; 1 8 18 21 25 26; 1 8 18 21 25 26};
surf(X,Y,Z);
  댓글 수: 2
allbert
allbert 2018년 4월 25일
It shows me this error
hh = matlab.graphics.chart.primitive.Surface(allargs{:});
Jan
Jan 2018년 4월 25일
This does not look like an error message. Do you get anything more on the screen?

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

채택된 답변

Jan
Jan 2018년 4월 25일
The curly braces are used to create cell arrays. You want numerical arrays and need square brackets:
A = [1;2;5;7;10;20];
B = [1;2;5;7;10;20]';
[X Y] = meshgrid(A,B);
Z = [1 8 18 21 25 26; 1 8 18 21 25 26; 1 8 18 21 25 26; ...
1 8 18 21 25 26; 1 8 18 21 25 26; 1 8 18 21 25 26];
surf(X,Y,Z);
And suddenly it works :-)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by