Perform discrete-time integration in MATLAB script
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
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
0 个评论
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');
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Digital Filter Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!