abcdefg 发表于 2007-12-29 11:31

Inner matrix dimensions must agree 出错求助

function yout=plot111
a=zeros(21,1);
n=0;
for i=1:21
    a(i)=(1/(pi*500000000000)).*exp(-40000.*n.^2).*dblquad(@fun,0,25,0,2*pi,[],[],n);
    i
    n=n+1;
end
n=1:20;
plot(n,a);
function z=fun(x,y,n)
    z=x.*(x.*cos(y)+20000.*n.^2).^2*(x.*sin(y)+20000.*n.^2).^2.*exp(-x.^2./(20000.*n.^2)-2.*x.*cos(y)-2.*x.*sin(y));


??? Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> plot111>fun at 12
    z=x.*(x.*cos(y)+20000.*n.^2).^2*(x.*sin(y)+20000.*n.^2).^2.*exp(-x.^2./(20000.*n.^2)-2.*x.*cos(y)-2.*x.*sin(y));
Error in ==> quad at 62
y = f(x, varargin{:});
Error in ==> dblquad>innerintegral at 88
    Q(i) = feval(quadf, intfcn, xmin, xmax, tol, trace, y(i), varargin{:});
Error in ==> quad at 62
y = f(x, varargin{:});
Error in ==> dblquad at 64
Q = feval(quadf, @innerintegral, ymin, ymax, tol, trace, intfcn, ...
Error in ==> plot111 at 5
    a(i)=(1/(pi*500000000000)).*exp(-40000.*n.^2).*dblquad(@fun,0,25,0,2*pi,[],[],n);
>>

[ 本帖最后由 eight 于 2007-12-29 14:39 编辑 ]

abcdefg 发表于 2007-12-29 11:58

我修改了一下
function yout=plot111
a=zeros(21,1);
n=0;
for i=1:21
    a(i)=(1/(pi*500000000000)).*exp(-40000*n.^2).*dblquad(@fun,0,25,0,2*pi,[],[],n);
    i
    n=n+1;
end
n=1:20;
plot(n,a);
function z=fun(x,y,n)
    z=x.*(x.*cos(y)+20000*n.^2).^2.*(x.*sin(y)+20000*n.^2).^2.*exp(-x.^2./(20000*n.^2)-2*x.*cos(y)-2*x.*sin(y));
怎么像以个死循环啊
大家帮我看看

sigma665 发表于 2007-12-29 12:05

回复 #3 abcdefg 的帖子

你的程序我复制后没法运行

eight 发表于 2007-12-29 14:38

攒取积分,然后到置顶帖中找答案

abcdefg 发表于 2007-12-29 15:59

是啊,我的也是老出现好多warning,你帮我看看哪里出错了啊,谢谢我实在查不出来
页: [1]
查看完整版本: Inner matrix dimensions must agree 出错求助