Sine wave to a straight line
13 views (last 30 days)
Show older comments
How can I filter a sine wave to make a smooth straight line?
0 Comments
Answers (1)
Star Strider
on 24 Mar 2015
Edited: Image Analyst
on 24 Mar 2015
Easiest way:
y = mean(x)*ones(size(x));
Otherwise, use a bandstop or notch filter at the frequency of the sine wave.
3 Comments
Image Analyst
on 24 Mar 2015
A straight line has the same y value for all x values. What y value do you want? How about the mean of your signal? Sounds reasonable, and that is what Star gave you. If you want some other value like the min, or max, or 42 or any other number then just replace mean(x) with your desired number.
Star Strider
on 24 Mar 2015
I outlined the steps in filter design a couple days ago in How to design a lowpass filter for ocean wave data in Matlab?.
Replace the appropriate references to 'lowpass' with 'bandstop' as ‘ftype’ in the butter function (or related functions if you choose another filter design), remembering that for a bandstop filter you will need to specify two frequencies — lower and upper — for the stopband.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!