2D plot from 3D Datasets

3 visualizaciones (últimos 30 días)
Hassan Strong
Hassan Strong el 21 de Jun. de 2020
Comentada: darova el 24 de Jun. de 2020
Hello,
I uploaded 3D datasets like this (given in Imz) and I can plot 3D slice as well. But now I want to plot each of the 2D slice seperately how can I do that?
clc
clear all
close all
%%%%Initialize
scaLe=0.01
pixel_endpointx=16*scaLe;
pixel_endpointy=16*scaLe;
pixel_endpointz=45*scaLe;
x_n=linspace(-pixel_endpointx,pixel_endpointx,50);
y_n=linspace(-pixel_endpointy,pixel_endpointy,50);
z_n=linspace(-pixel_endpointz,pixel_endpointz,50);
X1=x_n;
Y1=y_n;
Z1=z_n;
[x_n,y_n,z_n]=meshgrid(X1,Y1,Z1);
x_n=x_n(:);
y_n=y_n(:);
z_n=z_n(:);
%%%%%%for plot
x1=x_n;
y1=y_n;
z1=z_n;
X=x_n;
Y=y_n;
Z=z_n;
Imz=csvread('Image_pixel.csv') %%%%size is row=50*50*50 by 1 column
range=100
xlin = linspace(min(X),max(X),range);
ylin = linspace(min(Y),max(Y),range);
zlin=linspace(min(Z),max(Z),range);
[XX,YY,ZZ] = meshgrid(xlin,ylin,zlin);
zi = griddata(x1,y1,z1,Imz./(max(Imz)),XX,YY,ZZ); %%%%interpolation
xslice = [-5]*scaLe;
yslice = [-3]*scaLe;
zslice = [-20,15]*scaLe;
slice(XX,YY,ZZ,zi,xslice,yslice,zslice)
colormap(jet(256))
colorbar
shading interp;
  2 comentarios
darova
darova el 22 de Jun. de 2020
Please attach the data. Can't run without it
Hassan Strong
Hassan Strong el 22 de Jun. de 2020
Here it is

Iniciar sesión para comentar.

Respuestas (1)

darova
darova el 23 de Jun. de 2020
try this way
zslice = [-20,15]*scaLe;
figure
slice(XX,YY,ZZ,zi,xslice,[],[])
figure
slice(XX,YY,ZZ,zi,[],[],zslice(1))
figure
slice(XX,YY,ZZ,zi,[],[],zslice(2))
figure
slice(XX,YY,ZZ,zi,[],yslice,[])
  2 comentarios
Hassan Strong
Hassan Strong el 23 de Jun. de 2020
Hi, I was asking 2D plot not 3D plot.
darova
darova el 24 de Jun. de 2020
Sorry, forgot about 2D. Try this
[x,y,z] = meshgrid(-2:.2:2,-2:.25:2,-2:.16:2);
v = x.*exp(-x.^2-y.^2-z.^2);
h = slice(x,y,z,v,1,[],[]);
pcolor(get(h,'cdata'))

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by