下記のプログラムのfor文の使用を1回と0回に減らしたいのですがfor文の使用回数を減らすにはどのように修正すればよいでしょうか?
clear all;
close all;
h=0;
rho=1000;
Ae=0.01;
t=1;
v=1500;
omega=2pi1000000;
k=omega/v;
r=0.1;
x_start=-0.003;
x_end=0.003;
num_div=50;
delta_x=(x_end-x_start)/num_div;
x=x_start:delta_x:x_end;
y_start=-0.003;
y_end=0.003;
delta_y=(y_end-y_start)/num_div;
y=y_start:delta_y:y_end;
[X,Y]=meshgrid(x,y);
P1=0;
for i=0:pi/60:pi/3
for j=0:pi/10:(2*pi-pi/10)
a=i;
b=j;
x1=rcos(b)sin(a);
y1=rsin(b)sin(a);
z1=rcos(a);
deltaS=r^2sin(a)(pi/60)(pi/10);
R=sqrt((X-x1).^2+(Y-y1).^2+(z1).^2);
P=(rhoAe.exp(1iomegat).deltaS)./(2pi.(R+h).exp(1ik(R+h)));
P1=P1+P;
end
end
P1=abs(P1);
mesh(X,Y,P1)
grid on
回答2件
あなたの回答
tips
プレビュー