我需要使用四边形方法集成到一个循环中。我无法创建外部文件并调用它,因为积分方程中的变量会随着循环而变化,所以我为了制作简单而切断了循环。它在 quad 方法行中给我一个错误 - 不知道如何修复它 - 确切地说是 KrInitialIntegratedPart 我得到的错误消息是:
使用内联/子引用时出错(第 13 行)内联函数的输入不足。
quad 中的错误(第 68 行)y = f(x, varargin{:});
newproj4 中的错误(第 39 行)KrInitialIntegratedPart= quad('(sin(x)) (exp(-AInitial/aInitial)) (db)', 0, fe)
clear all;
clc;
%% All the constants and initial conditions
% the position conponents are "r" and "z"
% the velocity conponents are "vr" and "vz"
% the initial position components
rInitial= 10; %kpc
zInitial= 0; %kpc
% the initial velocity components
vrInitial= 0; %km/s
vzInitial= 150; %tangential velocity component
vtInitial= 150; %not used
% the height
h= rInitial*vzInitial; %angulan momentum constant
tInitial=0;
Dt=1e-3;
%ThetaiPlus1= Thetai + ( ( Dt*h ) / ( riPlus1Over2^2 ) );
%% The for loop
% the position components
riPlus1Over2= rInitial + 0.5*Dt*vrInitial;
ziPlus1Over2= zInitial + 0.5*Dt*vzInitial;
% integrating to solve for the acceleration components
% needed for the integration
b=0;
e=0.99;
pc=11613.5;
AInitial= (1/e)*sqrt( ( rInitial^2*( sin(0) )^2 ) + ( zInitial^2*( tan(0) )^2 ) );
aInitial=2.8;
fe=asind(e); % the upper limit of th integral
db= fe / 20; %4.094519277200290
% solving for the accleration compoenet in the r diection
KrInitialIntegratedPart= quad('(sin(x))*(exp(-AInitial/aInitial))*(db)', 0, fe)
KrInitialFirstPart= -4*pi*pc*sqrt( 1-(e^2) / (e^3) )*rInitial;
KrInitial= KrInitialFirstPart*KrInitialIntegratedPart;