ow to convert a 3Dplot to 2D?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (1)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!