Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
facing problem to plotting surface plot from imported data
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hi all, i m facing a problem in ploting the surface in 3 d. i have 3 data which i import from listing file having x coordinate in first column, y coordinate in second column nd the displacement values corresponding to that (x,y) coordinate in third column. now how i plot these values using surf() function. when i use these data directly it gives an error that z must be matrix . please help me to solve this.
my coding is
node=coordinate(:,1);
x=coordinate(:,2);
y=coordinate(:,3);
ux=uxdata(:,2);
surf(x,y,ux);
0 commentaires
Réponses (2)
Walter Roberson
le 14 Oct 2012
griddata() or use triscatterinterp to interpolate over the grid.
0 commentaires
Jonathan Epperl
le 14 Oct 2012
Modifié(e) : Jonathan Epperl
le 14 Oct 2012
As a quick workaround, use
plot3(x,y,ux,'.');
If you want to use surf or mesh because it looks prettier, then here is what your problem is: surf(X,Y,Z) needs matrices as input because it creates a tile between
[X(i,j) Y(i,j) Z(i,j)]
[X(i+1,j) Y(i+1,j) Z(i+1,j)]
[X(i,j+1) Y(i,j+1) Z(i,j+1)]
[X(i+1,j+1) Y(i+1,j+1) Z(i+1,j+1)]
See what the problem with your data is? Matlab has no idea which nodes to connect. So let's hope and assume that your data is in a somewhat useful form anyway, namely
x = [1 2 3 1 2 3 1 2 3];
y = [1 1 1 2 2 2 3 3 3];
% ux = [ux(1,1) ux(2,1) etc..]
ux = [pi 3 0 .3 10 -3 -1 .1 pi];
Then, you need to reshape your data into matrices so that adjacent indices work as described above: X = reshape(x,3,3); Y = reshape(y,3,3); U = reshape(ux,3,3); surf(X,Y,U)
1 commentaire
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!