Perform discrete-time integration in MATLAB script

조회 수: 17 (최근 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 CenterFile Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by