How do I plot 3d graphs using just matrices Values

8 ビュー (過去 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 :-)
  1 件のコメント
allbert
allbert 2018 年 4 月 25 日
Thank you very very much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by