필터 지우기
필터 지우기

discrete time histories generation

조회 수: 4 (최근 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 CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by