Asked by kunle
on 11 May 2012

I have a code written to integrate an accelerometer data to displacement. this code integrates the signal.

The code includes a butterworth high pass filter and the "cumtrapz" integration code.

Applying the code to a square wave, the wave becomes distorted. Does it mean my code is not good enough or the square wave will always be distorted by the filter.

Thanks in advance.

*No products are associated with this question.*

Answer by Elige Grant
on 11 May 2012

Accepted answer

Instead of trying to convert using your code, try mine located here:

http://www.mathworks.com/matlabcentral/answers/21700-finding-the-velocity-from-displacement

Say your acceleration data is called "square_acceleration_data", then (once you save my **iomega.m** file in a location Matlab can find it, like your Matlab home directory) you would produce your displacements like this:

square_displacement_data = iomega(square_acceleration_data,dt,3,1);

where "dt" is equal to your time increment (i.e., 1/Fs or 1 over your sampling frequency).

Example:

Elige Grant
on 14 May 2012

Answer by Walter Roberson
on 11 May 2012

It could mean both, but Yes, a square wave will always be distorted by any frequency filter.

square waves (and all other kinds of waves with straight edges... other than the constant signal of course) require infinite signal bandwidth to represent properly. Remove any frequency from that bandwidth (by way of filtering) and the square wave will be distorted. You often get "overshoot" on the leading and trailing edges as well.

Opportunities for recent engineering grads.

## 0 Comments