ploting 2 variable function
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
sixwwwwww
il 12 Ott 2013
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
Risposte (1)
Yatin
il 14 Ott 2013
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 Commenti
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!