facing problem to plotting surface plot from imported data
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
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);
Antworten (2)
Walter Roberson
am 14 Okt. 2012
1 Stimme
griddata() or use triscatterinterp to interpolate over the grid.
Jonathan Epperl
am 14 Okt. 2012
Bearbeitet: Jonathan Epperl
am 14 Okt. 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 Kommentar
Walter Roberson
am 14 Okt. 2012
scatter3(x,y,ux) is probably more appropriate.
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!