hi, i use the following code . the output is 15 values , i want stored this values automatically in array in order to Call these values again
3 ビュー (過去 30 日間)
古いコメントを表示
for sw=1:15
n=[10;20;30;40;50;60;70;80;90;100];phi=0.5;
s=2;
z0=0.4;
index=0;
o=10;
for nn=1:o
a=normrnd(0,s^2,n(nn),1);
z=zeros(n(nn),1);
z(1)=phi*z0+a(1);
for i=2:n(nn)
z(i)=phi*z(i-1)+a(i);
end
for i=2:n(nn)
g(i)=z(i)*z(i-1);
end
k=sum(g,2);
num= (n(nn)-2)*k;
for i=3:n(nn)
f(i)=z(i-1)*z(i-1);
end
p=sum(f,2);
den=(n(nn)-1)*p;
index=index+1;
ma(index)=n(nn);
phihat(index)=num/den;
end
for i=1:o
da(i)=(phihat(i)-phi)^2;
end
MSEreal=num2str((sum (da)/(o)),'% .10f')
end
0 件のコメント
採用された回答
Star Strider
2016 年 8 月 24 日
I would just do:
MSEreal(sw) =sum((da)/(o));
There’s absolutely no need to convert them to a string array, since you have to convert them back to numeric to use them later. If you want to round them to 10 digits to the right of the decimal, use the latest version of the round function, or this anonymous funciton to do the same thing:
roundn = @(x,n) round(x .* 10.^n)./10.^n; % Round ‘x’ To ‘n’ Digits, Emulates Latest ‘round’ Function
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!