Subscripted assignment dimension mismatch?
Ex=25; En=3; He=0.1; n=50;X=zeros(1,n); Y=zeros(1,n);
X(1:n)=normrnd(En,He,1,n);
for i=1:n
En1=X(1,i);
X(1,i)=normrnd(Ex,En1,1,n);
Y(1,i)=exp(-(X(1,i)-Ex)^2/(2*En1^2));
end
plot(X,Y); hold off
??? Subscripted assignment dimension mismatch.
好心人帮帮忙,急用!刚刚学习,马上要用,大家帮帮忙!
[ 本帖最后由 ChaChing 于 2009-8-12 21:03 编辑 ]
解决了
Ex=1; En=0.05; He=0.005; n=20;X=zeros(1,n); Y=zeros(1,n);
X(1:n)=normrnd(En,He,1,n);
for i=1:n
En1=X(1,i);
X(1,i)=normrnd(Ex,En1,1);
Y(1,i)=exp(-(X(1,i)-Ex)^2/(2*En1^2));
end
plot(X,Y); hold off
中
X(1,i)=normrnd(Ex,En1,1);多了n
[ 本帖最后由 ChaChing 于 2009-8-12 21:05 编辑 ]
页:
[1]