Solving Time Delay Integral?

4 ビュー (過去 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 Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by