second order to first order

3 views (last 30 days)
Cesar Cardenas
Cesar Cardenas on 23 Aug 2022
Answered: Cesar Cardenas on 24 Aug 2022
Hello, I'm trying to convert this system to as described here:
This is my attempt but not sure...any help will be greatly appreciated. Thanks
syms x(t)
eqn = diff(x,2) + diff(x,t)*x == u;
V = odeToVectorField(eqn)

Accepted Answer

Sam Chak
Sam Chak on 24 Aug 2022
I suspect that your 2nd-order ODE was incorrectly written. Please check. If it is a linear damped spring system, then the equation should be:
and it can be converted to the state-space form as shown below:
omega = 2;
zeta = sqrt(3)/4;
sympref('AbbreviateOutput', false);
syms x(t) y(t) u
eqn = diff(x, 2) + 2*zeta*omega*diff(x) + (omega^2)*x == (omega^2)*u;
[V, S] = odeToVectorField(eqn)
V = 
S = 
From the result, and , and so, the state-space model can be constructed accordingly:
A = [0 1; -4 -sqrt(3)];
B = [0; 4];
C = [1 0];
D = 0;
sys = ss(A, B, C, D)
sys = A = x1 x2 x1 0 1 x2 -4 -1.732 B = u1 x1 0 x2 4 C = x1 x2 y1 1 0 D = u1 y1 0 Continuous-time state-space model.

More Answers (1)

Cesar Cardenas
Cesar Cardenas on 24 Aug 2022
Hi @Sam Chak, thanks much for your help. I think it is a damped spring system. I would have an additional question.
For part c (based on the image below), this is my attempt: (not sure though). and do not really know how to work out part d regarding discrete time histories. Could you please give me any clue?? Thanks much once again.
%x(t) = 0.5*x(k-1) + y(k-1)
%y(t) = -0.5*x(k) + y(k)
%x(1) = 1, y(1) = 1
timesteps=30;
x = zeros(1, timesteps);
y = zeros(1, timesteps);
x(1) = 1;
y(1) = 1;
for k=2:timesteps
x(k) = 0.5*x(k-1) + y(k-1);
y(k) = -0.5*x(k) + y(k);
end
plot(1:timesteps,x, '-b', 'Linewidth' ,3);
hold on
plot(1:timesteps,y,'--r', 'Linewidth',3);
xlabel('time');
ylabel('Quantity')
legend('x','y')
figure(2)
plot(x,y)
xlabel('x')
ylabel('y')

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!