How to normalize the sine wave for the given code below?

I want to normalize the sine wave so that the amplitude is between 1 and -1.
fs = 48000;
N = 100000 ;
t = linspace(0,10,N); % seconds
period = 1;
amplitude = t;
y = (amplitude .* sin(2 * pi * t / period)); %sine wave
MaxNoise = 4 ;
Noise = linspace(MaxNoise,0,N) .* randn(1,N) ; % increasing noise
%z = flip(Noise); % decreasing noise
x = Noise + y ;
plot(t, x, 'b-', t, y, 'r-') ;
[frameval,k] = tonalframes(x, fs, 0.1);
figure;
plot(k,frameval);
xlabel('Time--->');
ylabel('Tonality--->');
title('Tonality Vs Time');

 採用された回答

Jos (10584)
Jos (10584) 2018 年 2 月 19 日

0 投票

y_normalised = 2*(y - mean(y)) ./ range(y) ;
or set the amplitude to 1 instead of t when you create the sinewave?

2 件のコメント

Manjunath Muntha Purushotham
Manjunath Muntha Purushotham 2018 年 2 月 19 日
Thanks for the reply. The reason why I am not setting the amplitude to 1 because I want it to increase linearly.
Manjunath Muntha Purushotham
Manjunath Muntha Purushotham 2018 年 2 月 19 日
Btw, thanks, it did work

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by