フィルターのクリア

ploting 2 variable function

1 回表示 (過去 30 日間)
ram
ram 2013 年 10 月 12 日
回答済み: Yatin 2013 年 10 月 14 日
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
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
ram
ram 2013 年 10 月 12 日
realy thank you for your help it works well :)

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

回答 (1 件)

Yatin
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);

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by