Filter out misalignment of sensor signal

Hi,
I have taken measurements with a lasersensor that moves along an axis and takes distance measurements to a wall for each position (1, 2, 3, ...). It seems that the axis that the sensor is mounted on is not perfectly parallel to the wall so that I can see a trend which you can see in the image below. The blue line is my acquired signal, the red lines describe the signal within a measurement position (X number of points for each measurement position).
How can I filter out the misaligned sensor axis and simulate a perfectly aligned axis that is parallel to the wall?
Thanks.

 Accepted Answer

I have no idea what ‘perfectly aligned axis’ means.
If you want to remove the baseline trend, the best option for this signal is likely a highpass or bandpass filter.
If you want a different result, please be specific.
.

8 Comments

Perfectly aligned axis means that I do not see the two peaks in my data. The signal should be flat where the data of the measured positions should be attached to each other without having the two peaks.
Try the filter approach.
To design the filters correctly, first do a Fourier transform (fft) on the signal to determine the appropriate bandpass or highpass frequencies. The highpass filter will elimiinate the baseline variation only, the bandpass filter will eliminate the baseline variation and high-frequency noise, if that is desiered.
Thanks for the advice but filtering will change the amplitude of the signal a lot. I think that each time the sensor moves to the next measurement position there is a jump/step in the signals which results in the overall trend you can see in the figure above. How do I remove the jump/step for each measurement position? The length of the signal for each measurement position is actually way smaller than shown in the figure. This is only done for illustration purposes. The signal consists of multiple measurements which are attached to each other.
I will have to have a representative signal to experiment with, and a description of the result you want, in order to proceed.
The filtering approach will likely work, unless the signal itself has low-frequency components that cannot be successfully separated from the baseline variation frequency. Other approaches may work if filtering does not. I cannot determine at present how to solve this, or if a solution is possible.
.
So I actually want to create a surface map of a laying cylindrical object. The data that is attached here is the Z-Height over the entire width for a specific angle (360° full angle).
You can notice the trend resulting from multiple measurements attached to each other. The signal should look more or less flat without steps. Each measured signal consists of 33 data points which are attached to each other to create the full width.
I am not certain how you calculated the values in the earlier plot image.
I developed this code for you to experiment with to see what works, since I have no idea what information you want in the filtered signal:
LD = load('DataZ.mat');
DataZ = LD.DataZ;
L = numel(DataZ);
x = linspace(0, L-1, L);
figure
plot(x, DataZ)
grid
Fs = 1/x(2);
Fn = Fs/2;
N = 2^nextpow2(L);
DataZm = DataZ-mean(DataZ);
FTDZ = fft(DataZm,N)/L;
Fv = linspace(0, 1, fix(numel(FTDZ)/2)-1)*Fn;
Iv = 1:numel(Fv);
figure
plot(Fv, abs(FTDZ(Iv))*2)
grid
xlim([0 0.025])
Flo = 6E-3; % Low Frequency Cutoff
Fhi = 1.5E-2; % High Frequency Cutoff
[DataZfilt,DF] = bandpass(DataZ, [Flo Fhi], Fs);
figure
plot(x, DataZfilt)
grid
Please experiment with this — specifically ‘Flo’ and ‘Fhi’ — to see if it produces the result you want (that I still do not have any idea about). It requires the Signal Processing Toolbox and MATLAB 2018a or later. (I can code an equivalent filter if you have an earlier version of the Toolbox.) The first figure is the original signal, the second is the Fourier transform (that can help guide the frequency values for the filter), and the third is the filtered signal.
.
Thanks, I will experiment with it a bit and yes, I do have the toolboxes.
As always, my pleasure!
Out of my own curiosity, I would like to see what the desired result looks like, and the filter frequencies used to derive it.
.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!