How to Turn Imagesc to x and y?

1 view (last 30 days)
Sushmitha Kudari
Sushmitha Kudari on 19 Feb 2020
Commented: Rik on 23 Feb 2020
I have the following file MunkS_500Hz.shd.mat,
munkProfile = load('MunkS_500Hz.shd.mat');
pressureWave = munkProfile.pressure;
pressureWave = abs(pressureWave);
squished = squeeze(pressureWave);
figure
plot(squished);
logged = log(squished)
imag = imagesc(logged);
that I can make into a 501 x 1001 matrix. Now I want to take this matrix from imagesc and put make it into a 3D point cloud. I would like some advice on how to do this. (I am unable to insert the file here even as a .zip file, I can email it to you if you think you can help).

Answers (2)

Rik
Rik on 19 Feb 2020
Edited: Rik on 19 Feb 2020
You can generate the coordinates with ndgrid and then you can linearize the three matrices and use them as input to plot3.
I=randi(255,501,1001);
[X,Y]=ndgrid(1:size(I,1),1:size(I,2));
plot3(X(:),Y(:),I(:),'.')
(untested code)
  5 Comments
Sushmitha Kudari
Sushmitha Kudari on 22 Feb 2020
I need to create a 3D point cloud of the logged = log(squished) . For this i need only its x and y components. So for example if this is my x and y:
X Y
1 1
1 8
2 8
5 6
2 5
I want to add a z-component to each so that I can plot it 3D space:
X Y Z
1 1 0
1 1 1
1 1 2
1 1 3
...
1 8 0
1 8 1
1 8 2
...
and so on
Rik
Rik on 23 Feb 2020
If you don't treat the pixel value as the z value, how are you using your data at all?

Sign in to comment.


Sushmitha Kudari
Sushmitha Kudari on 21 Feb 2020
I am trying to replicate this model (without the animation) using x and y from the logged. I want to make a 360 degree point cloud model by replicating x and y on different x planes.
%%will plot the formation of ripples on water surface ('_') ->
clear all
clc
x=-50:0.5:50;
y=-50:0.5:50;
[X,Y] = meshgrid(x,y); % create rectangular mesh
R=sqrt(X.^2+Y.^2); %radius
k=0.1; % wave vector
phi=0; % phase
count=1;
for freqrps=0.1:0.1:2*pi
Z=sin((2*pi-freqrps)*k*R);
surf(X,Y,Z,'Facecolor','blue','Edgecolor','none');
axis equal;
camlight right ;
lighting phong;
M(count)=getframe;
count=count+1;
end

Community Treasure Hunt

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

Start Hunting!