Double Integration problem
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (2)
Walter Roberson
am 12 Aug. 2011
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
am 12 Aug. 2011
0 Stimmen
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.
Kategorien
Mehr zu MATLAB Support Packages finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!