Integrating acceleration to get velocity and position in Simulink

4 views (last 30 days)
I have used the following code in an interpreted matlab function in Simulink to get velocity (and then position) from acceleration but it throws all zeros. I would be thankful if anyone could help. (Data is collected from a sensor with a frequency of 50 Hz)
function y = fcn(u) d = designfilt('lowpassiir', ... % Response type 'PassbandFrequency',20, ... % Frequency constraints 'StopbandFrequency',22, ... 'PassbandRipple',4, ... % Magnitude constraints 'StopbandAttenuation',25, ... 'DesignMethod','cheby2', ... % Design method 'MatchExactly','passband', ... % Design method options 'SampleRate',50); x = filter(d,u); y = cumtrapz(x);

Answers (0)

Community Treasure Hunt

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

Start Hunting!