Perform discrete-time integration in MATLAB script
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (2)
waqar mehboob
on 1 Nov 2018
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
0 Comments
Preksha
on 17 Jul 2024
% 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');
0 Comments
See Also
Categories
Find more on Digital Filter Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!