필터 지우기
필터 지우기

How to straighten a sinusoidal signal?

조회 수: 7 (최근 30일)
Chinwe Orie
Chinwe Orie 2018년 6월 25일
댓글: Chinwe Orie 2018년 6월 26일
I have a signal that bouncy (the waves are all over the place), and I've been trying to filter out the bouncy signals without changing the amplitude of the whole signal. Basically, I'd like a sinusoidal signal that is somewhat straight (doesn't have to be perfect). The data from the signal was imported from an excel file.
I have attached an image of what one of my signals look like. The problem with that particular signal is that little dip at the end of the signal that is very uneven with the rest of the waves.
Thanks for your help!
  댓글 수: 5
Chinwe Orie
Chinwe Orie 2018년 6월 25일
Yes. I planned to take the envelope peaks of the signal and then subtract the upper envelopes from the lower ones to get the amplitude, but at the end the signal is uneven so taking the envelopes wouldn't be accurate there.
Greg Dionne
Greg Dionne 2018년 6월 26일
There are a few ways to do this. Image Analyst's approach is good (remove the discontinuity, then filter). You can then view the spectrum (or spectrogram) to obtain the amplitude of the filtered signal.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2018년 6월 26일
It looks like the signal is going along just fine until suddenly there is a big jump, and then it's fine again. So rather than filter the whole signal, I'd just identify the jump locations, determine the new offset, and subtract that from the signal. Here is the code. It's s fast and simple for loop.
% Initialization steps.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
xy = xlsread('capture 2.xls');
x = xy(:, 1);
y = xy(:, 2);
subplot(3, 1, 1);
plot(x, y, 'b-');
grid on;
title('Original Signal', 'FontSize', fontSize);
subplot(3, 1, 2);
differences = [0; diff(y)];
plot(x, differences, 'b-');
grid on;
title('Difference Signal', 'FontSize', fontSize);
offset = 0;
for k = 1 : length(y)
if abs(differences(k)) > 0.001
offset = differences(k);
end
correctedSignal(k) = y(k) - offset;
end
subplot(3, 1, 3);
plot(x, correctedSignal, 'b-');
title('Corrected Signal', 'FontSize', fontSize);
grid on;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
I think it does a pretty good job, don't you?
  댓글 수: 1
Chinwe Orie
Chinwe Orie 2018년 6월 26일
This is more than a good job. Works with some other signals I have to. Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2018년 6월 25일
I's use conv() to scan the signal with a window that covers an integer number of periods. Then I'd subtract the mean from the original signal. Something like
windowWidth = 31; % Whatever works.
kernel = ones(windowWidth, 1)/windowWidth;
slidingMean = conv(signal, kernel, 'same');
correctedSignal = signal - slidingMean;
See how that works.
  댓글 수: 3
Image Analyst
Image Analyst 2018년 6월 26일
Attach your data if you want more help.
Chinwe Orie
Chinwe Orie 2018년 6월 26일
Here it is. First column is the time and the second is the voltage signal.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with Signal Processing Toolbox에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by