Solving Time Delay Integral?

조회 수: 1 (최근 30일)
Saanen
Saanen 2015년 12월 21일
답변: Rebecca Krosnick 2015년 12월 23일
Hi,
When trying to integrate this guy:
fD= @(r) (1/(1-rs/r)).*((1-((b^2)./(r.^2)).*(1-(rs/r))).^(-1/2)-1);
I get the error:
Error using /
Matrix dimensions must agree.
Error in @(r)(1/(1-rs/r)).*((1-((b^2)./(r.^2)).*(1-(rs/r))).^(-1/2)-1)
Error in integralCalc/iterateScalarValued (line 315)
fx = FUN(t);
Error in integralCalc/vadapt (line 133)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 84)
[q,errbnd] = vadapt(@AToInfInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in Bolometric_Flux (line 42)
t=integral(fD,R,Inf);*
This is the full code. Matlab can solve the commented out integral (f) but for some reason it won't work for (fD).
for k=1:length(a);
b=(R/(sqrt(1-u)))*sin(a(k));
%f= @(r) (1./r.^2).*(1/(b(k).^2)-(1./r.^2).*(1-(rs./r))).^(-1/2); %light bending integrand
fD= @(r) (1/(1-rs/r)).*((1-((b^2)./(r.^2)).*(1-(rs/r))).^(-1/2)-1); %time delay integrand
t=integral(fD,R,Inf);
%triangle_phi(i)=2*pi*h*triangle_t(i);
end
R,u and rs are defined in the code.

답변 (1개)

Rebecca Krosnick
Rebecca Krosnick 2015년 12월 23일
How is rs defined? If it is not a scalar, then the error is caused by
1/(1-rs/r)
You cannot divide the scalar "1" by a matrix. You instead need to use element-wise division like you have elsewhere in your code. Specifically, the code would instead be:
1./(1-rs/r)
Otherwise, to troubleshoot the issue, break down your definition of fD into variables. Define a variable for each matrix, and then compare the dimensions of the matrices to ensure they are appropriate for each /, ./, and .* operation.

카테고리

Help CenterFile Exchange에서 Matrix Computations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by