我在mathematica中有以下内容并想在matlab中使用它。我试过但我有错误并且无法修复它们。这是我还没有得到matlab哲学!所以,
intMC = {}; sigmat = {};
Do[np1 = np + i*100;
xpoints = Table[RandomReal[], {z1, 1, np1}];
a1t = Table[f[xpoints[[i2]]], {i2, 1, np1}];
a12 = StandardDeviation[a1t]/Sqrt[Length[a1t]];
AppendTo[intMC, {np1, Mean[a1t], a12}];
AppendTo[sigmat, {np1, a12}],
{i, 1, ntr}];
我这样做了:
fx=@ (x) exp(-x.^2);
intmc=zeros();
sigmat=zeros();
for i=1:ntr
np1=np+i*100;
xpoints=randn(1,np1);
for k=1:np1
a1t=fx(xpoints(k))
end %--> until here it prints the results,but in the
%end it gives
% me a message " Attempted to access xpoints(2,:);
%index out of bounds because size(xpoints)=[1,200]
%and stops executing.
%a1t=fx(xpoints(k,:)) % -->I tried this instead of the above but
%a1t=bsxfun(@plus,k,1:ntr) % it doesn't work
a12=std(a1t)/sqrt(length(a1t))
intmc=intmc([np1 mean(a1t) a12],:) %--> i can't handle these 3 and
sigmat=sigmat([np1 a12 ],:) %as i said it stopped executing
end