visualization of 3D matrix: how do I swap the y and z axis?

20 vues (au cours des 30 derniers jours)
Andreas W.
Andreas W. le 29 Fév 2012
The Matlab ordering for 3D matrices are: column (y) - row (x) - page (z).
I am using imagesc() to display slices of seismic data: imagesc( S(:,:,1) ); % first page
My first problem is this: how do I slice in another direction? imagesc( S(:,1,:) ); does not work :-(.
My next problem is that for seismic it is customary to have z axis downwards: column=z, row=x, page=y.
I have solved this by a "hack": when reading in the data from an ascii file I swap the y and z axes. The result is that imagesc( S(:,:,1) ); in reality is displaying the seismic for y=y1.
There must be some better way to do this?
Thanks in advance for any answers!

Réponse acceptée

Andrew Newell
Andrew Newell le 29 Fév 2012
You can use permute to rearrange the order of the dimensions and axis to to place the origin in the upper left corner:
S = permute(S,[3 1 2]);
% Your plot commands
axis ij
  1 commentaire
Andreas W.
Andreas W. le 29 Fév 2012
Thanks Andrew. That worked beautifully :-).

Connectez-vous pour commenter.

Plus de réponses (1)

Wayne King
Wayne King le 29 Fév 2012
Hi Andreas, you are using imagesc() to display 3D data??
Are you sure you are not talking about surf() or something other display method? imagesc() does not work on a 3D matrix except for a truecolor image.
If you use surf(), you can reverse the Z-axis direction
k = 5;
n = 2^k-1;
[x,y,z] = sphere(n);
surf(x,y,z); set(gca,'ydir','reverse');
  1 commentaire
Andreas W.
Andreas W. le 29 Fév 2012
Hi Wayne. Sorry for a poorly explained question. I have improved my question text.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Geographic Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by