discrete time histories generation

1 回表示 (過去 30 日間)
Cesar Cardenas
Cesar Cardenas 2022 年 8 月 25 日
回答済み: arushi 2023 年 10 月 18 日
how can I generate discrete time series? for part C (image below) this is my attempt:
omega = sqrt(2);
zeta = 1/sqrt(2);
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)
A = [0 0; -2 -2];
B = [2; 0];
C = [1 0];
D = 0;
sys = ss(A, B, C, D)
However, for part D, not sure what would be a right approach? Any help will be greatly appreciated. Thanks much.

回答 (1 件)

arushi
arushi 2023 年 10 月 18 日
Hi Cesar,
 I understand that you want to generate the discrete time series for part D using the results of the variables in part C.
Please find the code below for the solution of part C in which the values A, B, C, D are used as calculated in the part C :
% Define the parameters
omega = sqrt(2);
zeta = 1/sqrt(2);
w = 2*pi/100;
N_TI = 100;
N_T2 = 50;
% Initialize variables
x_TI = zeros(1, N_TI);
x_T2 = zeros(1, N_T2);
% Generate discrete-time histories for TI system
for k = 3:N_TI
u = sign(cos(2*w*k)); % Input signal
x_TI(k) = -2*x_TI(k-1) - 2*x_TI(k-2) + 2*u; % Update state variable
end
% Generate discrete-time histories for T2 system
for k = 3:N_T2
u = sign(cos(2*w*k)); % Input signal
x_T2(k) = -2*x_T2(k-1) - 2*x_T2(k-2) + 2*u; % Update state variable
end
% Plot the results
k_TI = 0:N_TI-1;
k_T2 = 0:N_T2-1;
figure;
hold on;
plot(k_TI, x_TI, 'b', 'LineWidth', 1.5);
plot(k_T2, x_T2, 'r', 'LineWidth', 1.5);
xlabel('k');
ylabel('x(k)');
legend('TI system', 'T2 system');
title('Discrete-time histories');
Hope this answer helps.

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by