当变量值太大时出现的问题
程序: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
elseifn>M/2+1
for jj=1:1:n-M/2, px1(jj)=(1-px1(jj)); end
end
px=; 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
elseifn0>N/2+1
for jj=1:1:n0-N/2, py1(jj)=(1-py1(jj)); end
end
py=;
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
= solve(S{:});
在论坛上好像没有这个问题!!!!!
[ 本帖最后由 ChaChing 于 2009-3-5 23:20 编辑 ] 哪位高人帮忙指点指点啊! 实在时头疼
当变量值太大时出现的问题
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
px py都是随机抽的数组,这个程序段在M与N较大时总是报错,为什么呀?
因为涉及抽样,所以M与N按要求应该都得上万. 已经帮忙合并了! 勿再重复发帖, 否则会被扣分!
还有LZ的帖子真的有点杂乱, 可能大家懒得看!
我记得曾试过看, 才一半就受不了! 记得发帖技巧很重要!
[ 本帖最后由 ChaChing 于 2009-3-2 19:01 编辑 ]
页:
[1]