马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
程序:
clear all
syms x u v
M=50; N=50; a=0.12; b=0.1; px=rand(1,M); px1=[]; px2=[]; j=1; k=1;
for i=1:1:M
if px(i)<0.5, px1(j)=px(i); j=j+1; else px2(k)=px(i); k=k+1; end
end
n=numel(px1)
if n<M/2-1
for ii=1:1:M/2-n, px2(ii)=(1-px2(ii)); end
elseif n>M/2+1
for jj=1:1:n-M/2, px1(jj)=(1-px1(jj)); end
end
px=[px1 px2]; py=rand(1,N); py1=[]; py2=[];
j=1;k=1;
for i=1:1:N
if py(i)<0.5, py1(j)=py(i); j=j+1;
else py2(k)=py(i); k=k+1; end
end
n0=numel(py1)
if n0<N/2-1
for ii=1:1:N/2-n0, py2(ii)=(1-py2(ii)); end
elseif n0>N/2+1
for jj=1:1:n0-N/2, py1(jj)=(1-py1(jj)); end
end
py=[py1 py2];
y=int((1/(sqrt(2*pi)*a))*exp(-(x-4)^2/(2*a^2)),u,inf);
for i=1:1:(M), A(i)=solve(y+px(i)-1); end
for i=1:1:M,
o=int((1/(sqrt(2*pi)*b))*exp(-(x-A(i))^2/(2*b^2)),v,inf);
for j=1:1:N, B(i,j)=solve(o+py(j)-1); end
end
x=sum(B(:))/numel(B);
for i=1:1:M, for j=1:1:N
F(i,j)=B(i,j)-x;
end; end
G=F.*F; a0=sum(G(:))/(M*N-1)
error=a0-a^2-b^2
a^2+b^2
error/(a^2+b^2)
再M与N较小时,没有问题.但当M与N上千时出现错误:Error using ==> maple
at offset 7, `]` unexpected
Error in ==> sym.findsym at 53
v = maple(['sort(',v,',lexorder)']);
Error in ==> solve at 125
total_vars = length(sym([ '[' findsym(seqns) ']' ]));
Error in ==> sym.solve at 49
[varargout{1:max(1,nargout)}] = solve(S{:});
在论坛上好像没有这个问题!!!!!
[ 本帖最后由 ChaChing 于 2009-3-5 23:20 编辑 ] |