ow to convert a 3Dplot to 2D?

์กฐํšŒ ์ˆ˜: 3 (์ตœ๊ทผ 30์ผ)
2NOR_Kh
2NOR_Kh 2022๋…„ 10์›” 28์ผ
ํŽธ์ง‘: DGM 2022๋…„ 10์›” 29์ผ
I have a code to generating phantom data in MATLAB but my final plot is in 3D. I searched throught mathwork and could find some solutions such as this one:
shading interp % this changes the color shading (i.e. gets rid of the grids lines on the surface)
view(2) % same as view(0, 90)
but this did not work on this plot
This is my code and results:
%1000 points randomly distributed in the square โˆ’5mm < ๐‘ฅ < 5mm,
%35mm < ๐‘ง < 45mm, y=0. Set the amplitude of the scatterers to 0 if they lie inside a circle of
%radius 2.5 mm centered at x=0, z=40 mm, and to 1 otherwise
clc;
close all;
clear all;
% field_init(-1);
% Create uniform target
% Define volume, number of scatterers
phantom_min_coords=[-5 0 35]*1e-3;
phantom_lengths=[10 0 10]*1e-3;
N_scatterers=1000;
% Generate scatter positions using Matlabโ€™s implicit expansion feature
% (Matlab 2016b or later)
positions=( rand(N_scatterers,3).*phantom_lengths )+phantom_min_coords;
%2.5mm radius cyst centered at (0,0,40)mm:
amplitudes=ones(N_scatterers,1);
for n=1:N_scatterers
if sum((positions(n,:)-[0 0 40]*1e-3).^2)<(2.5e-3)^2
amplitudes(n)=0;
end
end
s=amplitudes==1;
figure,plot3(positions(s,1)*1e3,positions(s,2)*1e3,positions(s,3)*1e3,'b.','MarkerSize',10);
hold on;
s=amplitudes==0;
plot3(positions(s,1)*1e3,positions(s,2)*1e3,positions(s,3)*1e3,'k.','MarkerSize',10);
% shading interp % this changes the color shading (i.e. gets rid of the grids lines on the surface)
% view(2) % same as view(0, 90)
I commented the final two lines of the code, however it did not work for this example.

๋‹ต๋ณ€ (1๊ฐœ)

DGM
DGM 2022๋…„ 10์›” 29์ผ
ํŽธ์ง‘: DGM 2022๋…„ 10์›” 29์ผ
Try this instead.
view([0 1 0])
In this case, the parameter is a unit vector defining the view orientation. You're looking at the y = 0 plane.
Using view(2) is the same as view([0 0 1]), and just gives you a view of the z = 0 plane

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ Surface and Mesh Plots์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

์ œํ’ˆ


๋ฆด๋ฆฌ์Šค

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by