second order to first order

3 次查看(过去 30 天)
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)

采纳的回答

Sam Chak
Sam Chak 2022-8-24
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.

更多回答(1 个)

Cesar Cardenas
Cesar Cardenas 2022-8-24
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')

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by