2D plot from 3D Datasets

조회 수: 3 (최근 30일)
Hassan Strong
Hassan Strong 2020년 6월 21일
댓글: darova 2020년 6월 24일
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
darova
darova 2020년 6월 22일
Please attach the data. Can't run without it
Hassan Strong
Hassan Strong 2020년 6월 22일
Here it is

댓글을 달려면 로그인하십시오.

답변 (1개)

darova
darova 2020년 6월 23일
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
Hassan Strong
Hassan Strong 2020년 6월 23일
Hi, I was asking 2D plot not 3D plot.
darova
darova 2020년 6월 24일
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'))

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by