2D plot from 3D Datasets
Ältere Kommentare anzeigen
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 Kommentare
darova
am 22 Jun. 2020
Please attach the data. Can't run without it
Hassan Strong
am 22 Jun. 2020
Antworten (1)
darova
am 23 Jun. 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 Kommentare
Hassan Strong
am 23 Jun. 2020
darova
am 24 Jun. 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'))
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!