Double Integration problem
古いコメントを表示
I am trying to integrate the following function.This is my code in matlab and the error messages:
pc=0;
f1 = (log(x) - log(31.1)./0.48).^2;
f2 = 2 .* pc .* ((log(x) - log(31.1)) ./ 0.48) .* ((log(y) - log(4.5)) ./ 0.58);
f3 = ((log(y) - log(4.5)) ./ 0.58) .^ 2;
P = @(x,y)(exp((-0.5 .* (f1 - f2 + f3)) ./ (1 - pc .^ 2))). / (2 .* pi .* x .* y .* 1.21 .* 0.9 .* sqrt(1 - pc .^ 2));
Q = dblquad(P,10,10000,10,10000)
Error using ==> mldivide
Matrix dimensions must agree.
Error in ==> @(x,y)(exp((-0.5.*(f1-f2+f3))./(1-pc.^2)))/(2.*pi.*x.*y.*1.21.*0.9.*sqrt(1-pc.^2))
Error in ==> quad at 76 y = f(x, varargin{:});
Error in ==> dblquad>innerintegral at 77 Q(i) = quadf(intfcn, xmin, xmax, tol, trace, y(i), varargin{:});
Error in ==> quad at 76 y = f(x, varargin{:});
Error in ==> dblquad at 53 Q = quadf(@innerintegral, ymin, ymax, tol, trace, intfcn, ...
I probably have syntax errors or maybe a dot is misplaced.I am new in Matlab and any help would be highly appreciated.Thank you.
採用された回答
その他の回答 (2 件)
Walter Roberson
2011 年 8 月 12 日
In your statement
P = @(x,y)(exp((-0.5 .* (f1 - f2 + f3)) ./ (1 - pc .^ 2))). / (2 .* pi .* x .* y .* 1.21 .* 0.9 .* sqrt(1 - pc .^ 2));
notice that you have ). / when instead you want ) ./
the cyclist
2011 年 8 月 12 日
0 投票
I don't get that error, because I cannot get past the syntax error in the definition of P. That line, as you have placed the parentheses, gives me an error: "Unexpected MATLAB operator."
Also, I assume f1,f2, and f3 are supposed to be their own function definition, but they are not, as you have written them.
カテゴリ
ヘルプ センター および File Exchange で MATLAB Support Packages についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!