hello, my code run one value only from loop(tt) and display one result from total result and then display the message "Subscripted assignment dimension mismatch." ,how to solve it ? and how know the line containning the error?
1 回表示 (過去 30 日間)
古いコメントを表示
s=[2;3;4;5;6;7;8;9]; z0=[0.3;0.4;0.2;0.6;0.7;0.8;0.9;0.5]; phi=[0.4;0.3;0.6;0.9;0.2;0.5;0.8;0.7]; for tt=1:8 index=7;index1=0; a=normrnd(0,(s(tt)).^2,15000,1);o=50; n=[300;350;400;480;500;600;650;700;800;900;1000;1200;1300;1500;1700;1900;2000;2100;2300;2500;2700;2900;3000;3300;3500;3900;4200;4400;4600;4900;5300;5700;5900;6000;6600;6800;7000;7100;7300;7500;7900;8200;8500;8700;8900;9000;9200;9500;9700;10000]; for nn=1:o z=[]; z(1)=phi(tt)*z0(tt)+a(1); for i=2:n(nn) z(i)=phi(tt)*z(i-1)+a(i); end for i=2:n(nn) g(i)=z(i)*z(i-1); end k1=sum(g,2); num= (n(nn)-2)*k1; for i=3:n(nn) f(i)=z(i-1)*z(i-1); end p=sum(f,2); den=(n(nn)-1)*p; d=min(z); h=max(z); k =7; L= (h-d)/k; intK = round(k); out=[linspace(d,h-L,intK)',linspace(d+L,h,intK)']; for i=1:n(nn) for j=1:k if (out(j,1)<=z(i)&z(i)<=out(j,2)) A(j,1,i)=z(i); end end end for i=1:k temp1=A(i,:,:); % whos temp1 temp2 = nonzeros(temp1); % whos temp2 temp3 = length(temp2); % w hos temp3 le(i)=temp3; end for i=1:k if(le(i)==max(le)) l=(out(i,2)-out(i,1))/4; index=length(out)+1; out(index,:)=[out(i,1) out(i,1)+l]; out(index+1,:)=[out(i,1)+l out(i,1)+2*l]; out(index+2,:)=[out(i,1)+2*l out(i,1)+3*l]; out(index+3,:)=[out(i,1)+3*l out(i,1)+4*l]; out(i,:)=[0 0]; end end t=max(le); for i=1:k if(le(i)==t) le(i)=0.5; end end for i=1:k if(le(i)==max(le)) l=(out(i,2)-out(i,1))/3; index=length(out)+1; out(index,:)=[out(i,1) out(i,1)+l]; out(index+1,:)=[out(i,1)+l out(i,1)+2*l]; out(index+2,:)=[out(i,1)+2*l out(i,1)+3*l]; out(i,:)=[0 0]; end end v=max(le); for i=1:k if(le(i)==v) le(i)=0.5; end end for i=1:k if(le(i)==max(le)) l=(out(i,2)-out(i,1))/2; index=length(out)+1; out(index,:)=[out(i,1) out(i,1)+l]; out(index+1,:)=[out(i,1)+l out(i,1)+2*l]; out(i,:)=[0 0]; end end for i=1:k if(le(i)==0) out(i,:)=[0 0]; end end format long g out; out( all(~out,2), : ) = []; u=[sort(out(:,1)) sort(out(:,2))]; for i=1:length(u) mid(i)=(u(i,1)+u(i,2))/2; q(i)=(u(i,2)-u(i,1))/4; down(i)=u(i,1)+q(i); up(i)=u(i,1)+3*q(i); len(i)=u(i,2)-u(i,1); end zz=[]; for j=1:length(u) if(u(j,1)<=z(2)&z(2)<=u(j,2)) zz(2)=mid(j); end end for j=1:length(u) if(u(j,1)<=z(3)&z(3)<=u(j,2)) mo=abs(z(2)-z(1)); if((mo)>len(j)) zz(3)=up(j); elseif ((mo)==len(j)) zz(3)=mid(j); elseif ((mo)<len(j)) zz(3)=down(j); end end end for r=3:(n(nn)-1) for i=1:length(u) if (u(i,1)<=z(r)&z(r)<=u(i,2)) for j=1:length(u) if (u(j,1)<=z(r+1)&z(r+1)<=u(j,2)) if (j>i) mo=abs((z(r)-z(r-1))-(z(r-1)-z(r-2))); if (((z(r)-z(r-1))-(z(r-1)-z(r-2)))>0) if((u(j,1)<=(mo*2+z(r))&(mo*2+z(r))<=u(j,2))|(u(j,1)<=(z(r)-mo*2)&(z(r)-mo*2)<=u(j,2))) zz(r+1)=up(j); elseif ((u(j,1)<=(mo/2+z(r))&(mo/2+z(r))<=u(j,2))|(u(j,1)<=(z(r)-mo/2)&(z(r)-mo/2)<=u(j,2))) zz(r+1)=down(j); else zz(r+1)=mid(j); end elseif (((z(r)-z(r-1))-(z(r-1)-z(r-2)))<0) if ((u(j,1)<=(mo/2+z(r))&(mo/2+z(r))<=u(j,2))|(u(j,1)<=(z(r)-mo/2)&(z(r)-mo/2)<=u(j,2))) zz(r+1)=down(j); elseif ((u(j,1)<=(mo*2+z(r))&(mo*2+z(r))<=u(j,2))|(u(j,1)<=(z(r)-mo*2)&(z(r)-mo*2)<=u(j,2))) zz(r+1)=up(j); else zz(r+1)=mid(j); end end elseif (j<i) mo=abs((z(r)-z(r-1))-(z(r-1)-z(r-2))); if (((z(r)-z(r-1))-(z(r-1)-z(r-2)))>0) if((u(j,1)<=(mo*2+z(r))&(mo*2+z(r))<=u(j,2))|(u(j,1)<=(z(r)-mo*2)&(z(r)-mo*2)<=u(j,2))) zz(r+1)=up(j); elseif ((u(j,1)<=(mo/2+z(r))&(mo/2+z(r))<=u(j,2))|(u(j,1)<=(z(r)-mo/2)&(z(r)-mo/2)<=u(j,2))) zz(r+1)=down(j); else zz(r+1)=mid(j); end elseif (((z(r)-z(r-1))-(z(r-1)-z(r-2)))<0) if ((u(j,1)<=(mo/2+z(r))&(mo/2+z(r))<=u(j,2))|(u(j,1)<=(z(r)-mo/2)&(z(r)-mo/2)<=u(j,2))) zz(r+1)=down(j); elseif ((u(j,1)<=(mo*2+z(r))&(mo*2+z(r))<=u(j,2))|(u(j,1)<=(z(r)-mo*2)&(z(r)-mo*2)<=u(j,2))) zz(r+1)=up(j); else zz(r+1)=mid(j); end end else mo=abs((z(r)-z(r-1))-(z(r-1)-z(r-2))); if (((z(r)-z(r-1))-(z(r-1)-z(r-2)))>0) if((u(j,1)<=(mo*2+z(r))&(mo*2+z(r))<=u(j,2))|(u(j,1)<=(z(r)-mo*2)&(z(r)-mo*2)<=u(j,2))) zz(r+1)=up(j); elseif ((u(j,1)<=(mo/2+z(r))&(mo/2+z(r))<=u(j,2))|(u(j,1)<=(z(r)-mo/2)&(z(r)-mo/2)<=u(j,2))) zz(r+1)=down(j); else zz(r+1)=mid(j); end elseif (((z(r)-z(r-1))-(z(r-1)-z(r-2)))<0) if ((u(j,1)<=(mo/2+z(r))&(mo/2+z(r))<=u(j,2))|(u(j,1)<=(z(r)-mo/2)&(z(r)-mo/2)<=u(j,2))) zz(r+1)=down(j); elseif ((u(j,1)<=(mo*2+z(r))&(mo*2+z(r))<=u(j,2))|(u(j,1)<=(z(r)-mo*2)&(z(r)-mo*2)<=u(j,2))) zz(r+1)=up(j); else zz(r+1)=mid(j); end end end end end end end end zz(1)=z(1); for i=2:n(nn) g2(i)=zz(i)*zz(i-1); end k2=sum(g2,2); num2= (n(nn)-2)*k2; for i=3:n(nn) f2(i)=zz(i-1)*zz(i-1); end p2=sum(f2,2); den2=(n(nn)-1)*p2; index1=index1+1; ma(index1)=n(nn); mb(index1)=phi(tt); phihat(index1)=num/den; phihat2(index1)=num2/den2; def(index1)=phihat2(index1)-phihat(index1); end for i=1:(o) table(i,:)=horzcat(ma(i),mb(i),phihat(i),phihat2(i),def(i)); end num2str(table,'% .4f') for i=1:(nn) da(i)=(phihat(i)-phi).^2; db(i)=(phihat2(i)-phi).^2; end ASD(tt)=sum (da)/(o) BSD(tt)=sum (db)/(o) end
1 件のコメント
Image Analyst
2016 年 8 月 31 日
Just attach with the paper clip icon, or see this http://www.mathworks.com/matlabcentral/answers/13205#answer_18099
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Software Development Tools についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!