Hi, I need to generate random points inside a parallelepiped

조회 수: 1 (최근 30일)
fatima-zahra achbah
fatima-zahra achbah 2017년 10월 6일
편집: fatima-zahra achbah 2017년 10월 6일
Hi guys, I need to generate a total i of points inside a specific parallelepiped(a*b*c) and plot it then after havings thoses points and their coordinations generate a sphere for each point.I already did a script but unfortunately it gives me a cube results :
clc close all a=10; % mm b=10; % mm depth=0.3; %mm i= 1145916; %total number of pores and thus of points inside the parallelepiped v=i*[]; Vt=a*b*depth; %volume expression mm^3 s = 10; n = bsxfun(@plus,0,s.*rand(i,3)); r=normrnd(0.005,0.001,[1 i]); %mu=0,005 mm ==>5µm x=n(:,1); y=n(:,2); z=n(:,3); scatter3(x,y,z,r,'fill') for k=1:i v(k)=(4*pi*(r(k)^3))/3; end figure plot(v) figure plot(r) figure subplot(3,1,1),histogram(x) subplot(3,1,2),histogram(y) subplot(3,1,3),histogram(z)
if true
clc
close all
a=10; % mm
b=10; % mm
depth=0.3; %mm
i= 1145916; %total number of pores and thus of points inside the parallelepiped
v=i*[];
Vt=a*b*depth; %volume expression mm^3
s = 10;
n = bsxfun(@plus,0,s.*rand(i,3));
r=normrnd(0.005,0.001,[1 i]); %mu=0,005 mm ==>5µm
x=n(:,1);
y=n(:,2);
z=n(:,3);
scatter3(x,y,z,r,'fill')
for k=1:i
v(k)=(4*pi*(r(k)^3))/3;
end
figure
plot(v)
figure
plot(r)
figure
subplot(3,1,1),histogram(x)
subplot(3,1,2),histogram(y)
subplot(3,1,3),histogram(z)
end
Best Regards

답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by