matlab运行出错
matlab程序出错,出现提示语:Subscriptindicesmusteitherberealpositiveintegersorlogicals.我的源程序如下,看...
matlab程序出错,出现提示语:Subscript indices must either be real positive integers or logicals.
我的源程序如下,看了老半天也没看出来,希望大家帮忙解决,谢谢!
T0=clock;
N=1024; %采样点数
wu=5*2*pi; %截断频率
dm=wu/N; %频率步长
dt=2*pi/(2*wu);%时间步长
k=0.003; %地面粗糙度系数
d=0.01;
f=d:d:10;
v10=20; %10米高处风速为20m/s
x=1200*f/v10;
s=4*k*v10*v10.*x.^2./f./(1+x.^2).^(4/3);%Davenport谱
z1=10; %取第一点为10米高度
z2=5; %取第二点为5米高度
r=0.12; %考虑地表粗糙度影响的无量纲幂指数
v5=v10*(z2/z1)^r;%计算n米高处的平均风速
C=10; %指数衰减系数(取经验值)
v1=zeros(2*N,1);
v2=zeros(2*N,1);
thta1=rand(N,1);
thta2=rand(N,1); %随机数
node=1;
for K=1:node
for j=1:2*N
sum1=0;
sum2=0;
for l=1: N
m1=l*dm-0.5*dm; m2=l*dm;
x1=1200*m1/(2*pi*v10);
s11=2*pi*4*k*v10*v10.*x1.^2./m1./(1+x1.^2).^(4/3);
x2=1200*m2/(2*pi*v10);
s22=2*pi*4*k*v5*v5.*x2.^2./m2./(1+x2.^2).^(4/3);
s12=sqrt(s11*s22).*exp(-2*m2*C*abs(z1-z2)./(2*pi*(v10+v5)));
s21=sqrt(s11*s22).*exp(-2*m1*C*abs(z1-z2)./(2*pi*(v10+v5)));
S=[s11 s12; s21 s22];
H=chol(S);
a1=abs(H(1,1));
H1=H;
a21=abs(H1(2,1));
a22=abs(H1(2,2));
b1=cos((m1*dt*(j-1))+2*pi*thta1(l,1));
b2=cos((m2*dt*(j-1))+2*pi*thta2(l,1));
c1=a1*b1;
c21=a21*b1;
c22=a22*b2;
d1=(dm).^0.5*c1;
d2=(dm).^0.5*(c21+c22);
sum1=sum1+d1;
sum2=sum2+d2;
end
sum1=2*sum1;
sum2=2*sum2;
v1(i,K)=sum1;
v2(j,K)=sum2;
end
end
time=etime(clock,t0); 展开
我的源程序如下,看了老半天也没看出来,希望大家帮忙解决,谢谢!
T0=clock;
N=1024; %采样点数
wu=5*2*pi; %截断频率
dm=wu/N; %频率步长
dt=2*pi/(2*wu);%时间步长
k=0.003; %地面粗糙度系数
d=0.01;
f=d:d:10;
v10=20; %10米高处风速为20m/s
x=1200*f/v10;
s=4*k*v10*v10.*x.^2./f./(1+x.^2).^(4/3);%Davenport谱
z1=10; %取第一点为10米高度
z2=5; %取第二点为5米高度
r=0.12; %考虑地表粗糙度影响的无量纲幂指数
v5=v10*(z2/z1)^r;%计算n米高处的平均风速
C=10; %指数衰减系数(取经验值)
v1=zeros(2*N,1);
v2=zeros(2*N,1);
thta1=rand(N,1);
thta2=rand(N,1); %随机数
node=1;
for K=1:node
for j=1:2*N
sum1=0;
sum2=0;
for l=1: N
m1=l*dm-0.5*dm; m2=l*dm;
x1=1200*m1/(2*pi*v10);
s11=2*pi*4*k*v10*v10.*x1.^2./m1./(1+x1.^2).^(4/3);
x2=1200*m2/(2*pi*v10);
s22=2*pi*4*k*v5*v5.*x2.^2./m2./(1+x2.^2).^(4/3);
s12=sqrt(s11*s22).*exp(-2*m2*C*abs(z1-z2)./(2*pi*(v10+v5)));
s21=sqrt(s11*s22).*exp(-2*m1*C*abs(z1-z2)./(2*pi*(v10+v5)));
S=[s11 s12; s21 s22];
H=chol(S);
a1=abs(H(1,1));
H1=H;
a21=abs(H1(2,1));
a22=abs(H1(2,2));
b1=cos((m1*dt*(j-1))+2*pi*thta1(l,1));
b2=cos((m2*dt*(j-1))+2*pi*thta2(l,1));
c1=a1*b1;
c21=a21*b1;
c22=a22*b2;
d1=(dm).^0.5*c1;
d2=(dm).^0.5*(c21+c22);
sum1=sum1+d1;
sum2=sum2+d2;
end
sum1=2*sum1;
sum2=2*sum2;
v1(i,K)=sum1;
v2(j,K)=sum2;
end
end
time=etime(clock,t0); 展开
展开全部
【1】i原来没有定义
T0=clock;
N=1024; %采样点数
wu=5*2*pi; %截断频率
dm=wu/N; %频率步长
dt=2*pi/(2*wu);%时间步长
k=0.003; %地面粗糙度系数
d=0.01;
f=d:d:10;
v10=20; %10米高处风速为20m/s
x=1200*f/v10;
s=4*k*v10*v10.*x.^2./f./(1+x.^2).^(4/3);%Davenport谱
z1=10; %取第一点为10米高度
z2=5; %取第二点为5米高度
r=0.12; %考虑地表粗糙度影响的无量纲幂指数
v5=v10*(z2/z1)^r;%计算n米高处的平均风速
C=10; %指数衰减系数(取经验值)
v1=zeros(2*N,1);
v2=zeros(2*N,1);
thta1=rand(N,1);
thta2=rand(N,1); %随机数
node=1;
for K=1:node
for j=1:2*N
sum1=0;
sum2=0;
for l=1: N
m1=l*dm-0.5*dm; m2=l*dm;
x1=1200*m1/(2*pi*v10);
s11=2*pi*4*k*v10*v10.*x1.^2./m1./(1+x1.^2).^(4/3);
x2=1200*m2/(2*pi*v10);
s22=2*pi*4*k*v5*v5.*x2.^2./m2./(1+x2.^2).^(4/3);
s12=sqrt(s11*s22).*exp(-2*m2*C*abs(z1-z2)./(2*pi*(v10+v5)));
s21=sqrt(s11*s22).*exp(-2*m1*C*abs(z1-z2)./(2*pi*(v10+v5)));
S=[s11 s12; s21 s22];
H=chol(S);
a1=abs(H(1,1));
H1=H;
a21=abs(H1(2,1));
a22=abs(H1(2,2));
b1=cos((m1*dt*(j-1))+2*pi*thta1(l,1));
b2=cos((m2*dt*(j-1))+2*pi*thta2(l,1));
c1=a1*b1;
c21=a21*b1;
c22=a22*b2;
d1=(dm).^0.5*c1;
d2=(dm).^0.5*(c21+c22);
sum1=sum1+d1;
sum2=sum2+d2;
end
sum1=2*sum1;
sum2=2*sum2;
v1(l,K)=sum1;
v2(j,K)=sum2;
end
end
time=etime(clock,T0);
望采纳
T0=clock;
N=1024; %采样点数
wu=5*2*pi; %截断频率
dm=wu/N; %频率步长
dt=2*pi/(2*wu);%时间步长
k=0.003; %地面粗糙度系数
d=0.01;
f=d:d:10;
v10=20; %10米高处风速为20m/s
x=1200*f/v10;
s=4*k*v10*v10.*x.^2./f./(1+x.^2).^(4/3);%Davenport谱
z1=10; %取第一点为10米高度
z2=5; %取第二点为5米高度
r=0.12; %考虑地表粗糙度影响的无量纲幂指数
v5=v10*(z2/z1)^r;%计算n米高处的平均风速
C=10; %指数衰减系数(取经验值)
v1=zeros(2*N,1);
v2=zeros(2*N,1);
thta1=rand(N,1);
thta2=rand(N,1); %随机数
node=1;
for K=1:node
for j=1:2*N
sum1=0;
sum2=0;
for l=1: N
m1=l*dm-0.5*dm; m2=l*dm;
x1=1200*m1/(2*pi*v10);
s11=2*pi*4*k*v10*v10.*x1.^2./m1./(1+x1.^2).^(4/3);
x2=1200*m2/(2*pi*v10);
s22=2*pi*4*k*v5*v5.*x2.^2./m2./(1+x2.^2).^(4/3);
s12=sqrt(s11*s22).*exp(-2*m2*C*abs(z1-z2)./(2*pi*(v10+v5)));
s21=sqrt(s11*s22).*exp(-2*m1*C*abs(z1-z2)./(2*pi*(v10+v5)));
S=[s11 s12; s21 s22];
H=chol(S);
a1=abs(H(1,1));
H1=H;
a21=abs(H1(2,1));
a22=abs(H1(2,2));
b1=cos((m1*dt*(j-1))+2*pi*thta1(l,1));
b2=cos((m2*dt*(j-1))+2*pi*thta2(l,1));
c1=a1*b1;
c21=a21*b1;
c22=a22*b2;
d1=(dm).^0.5*c1;
d2=(dm).^0.5*(c21+c22);
sum1=sum1+d1;
sum2=sum2+d2;
end
sum1=2*sum1;
sum2=2*sum2;
v1(l,K)=sum1;
v2(j,K)=sum2;
end
end
time=etime(clock,T0);
望采纳
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询