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!