提示Index exceeds matrix dimensions,改变矩阵维数变量又不提
本帖最后由 benyou 于 2012-6-15 17:30 编辑由于matlab不熟,现在写论文编了一个程序不知道为什么,我改变参数10到48(也就是矩阵的维数)就会提示Index exceeds matrix dimensions。谁能帮忙指点下错误的地方,程序如下:
function main
clear all
rand('state',0);
randn('state',0);
N_dot=48;%改成10就行了可是我就得用到48乘以48的啊,怎么办?
p=1000;
ax=;
az=;
v10=30;
alpha=0.22;
k=0.00464;
delta_t=0.2;
Uz=v10*(az/10).^alpha;%产生功率谱
vvd=0.4*v10/2.302585;
N=p;
posi=zeros(N_dot,N_dot,N);
ch=zeros(N_dot,N_dot,N);
S=zeros(N_dot,N_dot,N);
H=zeros(N_dot,N_dot,N);
dw=10*pi;
dltw=dw/N;
for m=1:1:N
mid1_S_H=zeros(N_dot,N_dot);
mid2_S_H=zeros(N_dot,N_dot);
n(m)=dw*m/N;%频率
f(m)=1200*n(m)/v10/2/pi;
Pn(m)=4*k*v10^2*f(m).^2/(1+f(m).^2).^(4/3);% 风速谱,如计算竖向Panofsky 谱将其替换为相应函数Uf=1;%摩擦速度
Su(m)=Pn(m)/n(m);
for g=1:N_dot
for h=1:N_dot
if g==h
ch(g,h,m)=1;
else
delta_z=sqrt(256*(ax(g)-ax(h)).^2+100*(az(g)-az(h)).^2);
ch(g,h,m)=exp(-2*n(m)/2/pi*delta_z/(Uz(g)+Uz(h)));
f_star=2*n(m)/2/pi*abs(az(g)-az(h))/(Uz(g)+Uz(h));
if f_star<=0.1
posi(g,h,m)=pi*f_star/4;
else if f_star<=0.125
posi(g,h,m)=-10*pi*f_star+1.25;
else posi(g,h,m)=pi-2*pi*rand(1);
end
end
end
end
end
for g=1:N_dot
for h=1:N_dot
S(g,h,m)=Su(m)*ch(g,h,m)*exp(i*posi(g,h,m));
mid1_S_H(g,h)=S(g,h,m);
end
end
=chol(mid1_S_H);
mid2_S_H=mid2_S_H';
clear g;
clear h;
for g=1:N_dot
for h=1:N_dot
H(g,h,m)=mid2_S_H(g,h);
end
end
end 这问题困扰了我两天了,没办法了,卡住了 按照错误提示,只要检查错误提示行数的Index 与相应的矩阵变量维数的关系即可。可以在workspace或者用size函数查看矩阵变量的维数 Ref: 常见的程序出错问题整理 http://forum.vibunion.com/thread-46001-1-1.html
12F->Index exceeds matrix dimensions. Attempted to access b(3,2); index out of bounds because size(b)=.
页:
[1]