How do I plot 3d graphs using just matrices Values

8 Ansichten (letzte 30 Tage)
allbert
allbert am 25 Apr. 2018
Kommentiert: allbert am 25 Apr. 2018
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 Kommentare
allbert
allbert am 25 Apr. 2018
It shows me this error
hh = matlab.graphics.chart.primitive.Surface(allargs{:});
Jan
Jan am 25 Apr. 2018
This does not look like an error message. Do you get anything more on the screen?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jan
Jan am 25 Apr. 2018
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 :-)

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots 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!

Translated by