How to clip a sine wave on both side?

조회 수: 5 (최근 30일)
Mohiuddin Mahbub
Mohiuddin Mahbub 2019년 7월 5일
댓글: Mohiuddin Mahbub 2019년 7월 5일
I want clip specific portion of both positive and negative side of sine wave.. How to do it. I used MinMax block but it only cliped one side..

답변 (1개)

Image Analyst
Image Analyst 2019년 7월 5일
First get the min and max values, then determine the threshold as some fraction from the center and clip:
maxy = max(y)
miny = min(y)
middley = (miny + maxy)/2;
% Determine top point as, say 90% ofthe way from the middle line to the max
fraction = 0.9;
upperThreshold = middley + fraction * (maxy - middley);
lowerThreshold = middley - fraction * (middley - miny);
% Now clip
indexesTooHigh = y > upperThreshold;
y(indexesTooHigh) = upperThreshold;
indexesTooLow = y < lowerThreshold;
y(indexesTooLow) = lowerThreshold;
  댓글 수: 1
Mohiuddin Mahbub
Mohiuddin Mahbub 2019년 7월 5일
I want to use it on Simulink..I am generating wave then I need to clip it and send it to another block..So is there any block model for this clip operation that can be done on both side of sine wave?

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

Community Treasure Hunt

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

Start Hunting!

Translated by