ploting 2 variable function
1 回表示 (過去 30 日間)
古いコメントを表示
Hello every one
i have some problem in plotting a two variable function
i have a matrix with (m x 3)points, so the firest column represent X and the second represent Y and the last column for Z with m points in each one
I have tried using
surf(matix(:,1),matix(:,2),matix(:,3))
but it give me a message error :Z must be a matrix, not a scalar or vector.
and also try to use:
X=[matix(:,1),matix(:,2)];
Z=matix(:,3);
surf(X,Z);
it draw a surf but it seem that it ignore Z
I will be appreciated if any one can help me
2 件のコメント
sixwwwwww
2013 年 10 月 12 日
To have surf plot you need to have Z a matrix of size m*n where m = length(X) and n = length(Y). See http://www.mathworks.com/help/matlab/ref/surf.html. But in your case you have vector. So you can use "plot3" or you create matrix Z
回答 (1 件)
Yatin
2013 年 10 月 14 日
Hi,
The length of vector X should be the same as number of columns of Z and the length of vector Y go with number of rows of Z .
Below is a sample code snippet:
[rows, cols] = size(Z);
X = 1:cols;
Y = 1:rows;
surf(X, Y, Z);
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!