Clipping an audio signal

조회 수: 4 (최근 30일)
MR T
MR T 2016년 12월 12일
답변: Greg Dionne 2016년 12월 12일
I want to clip an audio signal X like this :
X(X>=(max(X)-0.5)) = max(X)-0.5;
X(X<=(min(X)+0.5)) = min(X)+0.5;
But with a for-loop. I've written this:
for k = 1:length(X)
if X(k)>=(max(X)-0.5)
X(k) = max(X)-0.5;
elseif X(k)<=(min(X)+0.5)
X(k) = min(X)+0.5;
end
end
But it does not seem to do the same thing. What am I doing wrong?

답변 (1개)

Greg Dionne
Greg Dionne 2016년 12월 12일
You're clobbering the values in your for-loop. Try defining maxX = max(X) and minX = min(X) before modifying X.

카테고리

Help CenterFile Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by