Solution of linear-time varying system in matlab

7 vues (au cours des 30 derniers jours)
ShooQ
ShooQ le 27 Juin 2022
Modifié(e) : Torsten le 27 Juin 2022
I tried the given below to get the solution of the linear-time varying equation using for-loop, but the solution is not right what I am getting using ode45. I don’t know where I am getting wrong while implementing this. Then I want to estimate the parameter g(t) using the gradient method.
r0 = 0.05;
L = 0.1;
d = 0.005;
w0 = 1.5;
Ts=10;
t=[0:Ts:800];
x0=[0 0 1]';
y0=1;
x_value=[];
for k=1:(length(t)) % Number of Iterations
x_value=[x_value x0];
g(k) = (2*r0*L*sinh((d*(k))/2))./(d*cosh((d*(k))/2)+L*sinh((d*(k))/2));
A0 = [ -0.5*g(k) -w0 0 ;
w0 -g(k)*0.5 0 ;
0 0 -g(k)];
B0 =[0; 0; -g(k)];
Q=integral(@(u) expm(A0*((k+1)*Ts)-u)*B0,(k*Ts),((k+1)*Ts), 'ArrayValued', true);
x0=expm(A0*Ts)*x0+Q;
end
plot(t,x_value(1,:),'r-','linewidth',1);
  19 commentaires
ShooQ
ShooQ le 27 Juin 2022
This is what I want, I want to to update A0 and B0 like A0(k) or A0(t(k)) and same as B0(k) or B0(t(k)) so that it update iteratively. I tried but it doesn't work, e.g.,
r0 = 0.05;
L = 0.1;
d = 0.005;
w0 = 1.5;
Ts=10;
t=[0:Ts:800];
x0=[0 0 1]';
y0=1;
A0=zeros(3,3);
B0=zeros(3,1);
x_value=[];
A_value=[];
B_value=[];
for k=1:(length(t)) % Number of Iterations
x_value=[x_value x0];
A_value=[A_value A0];
B_value=[B_value B0];
for k=1:(length(t)) % Number of Iterations
x_value=[x_value x0];
g(k) = (2*r0*L*sinh((d*(k))/2))./(d*cosh((d*(k))/2)+L*sinh((d*(k))/2));
A0(k) = [ -0.5*g(k) -w0 0 ;
w0 -g(k)*0.5 0 ;
0 0 -g(k)];
B0(k) =[0; 0; -g(k)];
Q(k)=integral(@(u) expm(A0(k)*((k+1)*Ts)-u)*B0(k),(k*Ts),((k+1)*Ts), 'ArrayValued', true);
x0(k+1)=expm(A0*Ts)*x0(k)+Q(k);
end
plot(t,x_value(1),'r-','linewidth',1);
Torsten
Torsten le 27 Juin 2022
Modifié(e) : Torsten le 27 Juin 2022
If these are the correct update formulae, the original code you posted was correct. You can't write A0(k)=..., B0(k) = ...; x0(k+1) = ... since the objects on the right-hand side (the ...) aren't scalar values, but vectors or matrices.
This code works, but must be wrong for the reason I already mentionned (g only depends on the loop index, but not on t):
r0 = 0.05;
L = 0.1;
d = 0.005;
w0 = 1.5;
Ts = 10;
t = 0:Ts:800;
x0=[0 0 1]';
A0=zeros(3,3);
B0=zeros(3,1);
x_value=[];
for k=1:length(t) % Number of Iterations
x_value=[x_value x0];
g = (2*r0*L*sinh((d*(k))/2))./(d*cosh((d*(k))/2)+L*sinh((d*(k))/2));
A0 = [ -0.5*g -w0 0 ;
w0 -g*0.5 0 ;
0 0 -g];
B0 =[0; 0; -g];
Q = integral(@(u) expm(A0*((k+1)*Ts)-u)*B0,(k*Ts),((k+1)*Ts), 'ArrayValued', true);
x0 = expm(A0*Ts)*x0+Q;
end
plot(t,x_value(3,:),'r-','linewidth',1);

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by