How can I perform this definite integral (int not working)?
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello, everyone,
I'm currently trying to solve some LTI and LTV equations that are related to each other, I have the logic on how to solve them with the general solution (I know I can work with ODE solvers but I'm making a comparison of the methods); but the main problem here is that I'm trying to solve an definite integral with int but Matlab is giving me the exact same expression as the line I typed. I read about it in other posts and about numerical integration, but the problem here is that I need to integrate this expression in terms of a symbolic variable.
Here's the code of what I'm trying to do, thanks in advance!
%% Sol. for Lyapunov, Gamma y Lambda. %%
% System:
A=[-1 0;0 -1];
B=[0;1];
C=[1 1];
CT = transpose(C);
D=0;
%% Sol. Lyapunov:
syms Q
% Gain rho:
EiA = eig(A);
crho = -2*min(real(EiA))
rho = crho + 0.001;
A_bS = 0.5*rho*eye(2) + A;
A_bST = transpose(A_bS);
Q_bS = CT*Q*C;
D_S = [1 0; 0 1]; % initial conditions of S(0)
% -- Analytic solution for Lyapunov:
syms t tau
t0 = 0;
tf = 10;
% Lyapunov solution:
S = expm(-A_bST*(t - t0))*D*expm(-A_bS*(t-t0)) + int(expm(-A_bST*(t-tau))*Q_bS*expm(-A_bS*(t-tau)),tau,t0,t)
vpa(S,4)
%% Lambda:
Si = inv(S);
A_bL = (A - Si*CT*Q*C);
% State-transition matrix:
syms x1_0 x2_0
X = [x1_0; x2_0];
dx = A_bL*X;
x1= int(dx(1),tau,t0,t)
x2= int(dx(2),tau,t0,t)
% Espec. of X:
x1_0 = 1; x2_0 = 0;
x1_1 = eval(x1);
x2_1 = eval(x2);
x1_0 = 0; x2_0 = 1;
x1_2 = eval(x1);
x2_2 = eval(x2);
X = [x1_1 x2_1;
x1_2 x2_2];
clear t0
syms t0
X_t0 = subs(X,t,t0);
Io = X*inv(X_t0); % State-transition matrix Io(t,t0)
vpa(Io,4)
t0 = tau;
X_tau = subs(X,t,tau);
Io_tau = X*inv(X_tau); % State-transition matrix Io(t,tau)
vpa(Io_tau,4)
% -- Analytic solution of Lambda:
x0_L = [1; 0]; % Initial conditions for X
clear t0
t0 = 0;
syms Di
phi = [Di];
Lmb = Io*x0_L + int(Io_tau*B*phi,tau,t0,tf) % hERE'S THE DEFINITE INTEGRAL I'M DEALING WITH
vpa(Lmb,4)
3 Commenti
Walter Roberson
il 27 Mar 2020
Shrug. Most functions do not have closed form integrals.
Also your t0 is 0, and both of your formula in Io_tau*B_L*phi go to one of the infinities as tau approaches 0. When I substitute in concrete numbers for the constants, and ask for a numeric integration, sure enough the result is one of the infinities.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Particle & Nuclear Physics in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!