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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by