Perform discrete-time integration in MATLAB script

2 ビュー (過去 30 日間)
John
John 2014 年 7 月 30 日
回答済み: Preksha 2024 年 7 月 17 日
Hi,
I would like to implement discrete-time integration of input signal in MATLAB script. For example, input signal is array x[k] for x(t)=Xsinwt
If frequency is f=10 Hz I can chose T=0.003 sec. When I tried with discrete-time integration (x-input, y-output)
y[n]=y[n-1]+0.5*T*(x[n]+x[n+1]), n>0, T=0.003
I changed a lot of y[0]=IC, but with no success. Do you know what can be the problem and how to determine IC automatically, because input signal can be in wide range of different types.
Tigar

回答 (2 件)

waqar mehboob
waqar mehboob 2018 年 11 月 1 日
You can use this script to help solve your problem. clc figure(close) % Simple Sine wave t=0:0.01:10; y=sin(2*t); plot (y) hold on; % Discrete time integration y1(1)=0; K=1; x(1)=0; T=0.015; for n=1:length(t) x(n+1) = x(n) + K*T*y(1,n); y1(n) = x(n); end plot(y1); grid on

Preksha
Preksha 2024 年 7 月 17 日
% Define the input signal and parameters t = 0:0.01:10; % Time array (s) Vin = sin(2*pi*10*t); % Input signal (V) R = 1000; % Resistance (Ohms) C = 0.01; % Capacitance (F) dt = t(2) - t(1); % Time step
% Define the op-amp integrator model num = [-R/C]; den = [1 R*C dt]; H = tf(num, den);
% Simulate the output signal Vout = lsim(H, Vin, t);
% Plot the input and output signals plot(t, Vin, t, Vout); xlabel('Time (s)'); ylabel('Voltage (V)'); title('Op-Amp Integrator'); legend('Input', 'Output');

カテゴリ

Help Center および File ExchangeDigital Filter Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by