Clipping an audio signal

5 ビュー (過去 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 Center および File ExchangeAudio 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