Pink noise with specific power P

16 次查看(过去 30 天)
I need to generate pink noise signal with a specific power P. I can't figure it out on how to do that using the built-in function. Any help?

采纳的回答

Star Strider
Star Strider 2023-8-26
编辑:Star Strider 2023-8-28
Create a scaling constant defined by:
k = sqrt(DesiredPower / ActualPower)
then multiply that by the original vector.
Equivalently:
newVector = sqrt(DesiredPower/mean(OriginalVector.^2)) * OriginalVector
The resulting vector has the desired power.
Try this —
vp = @(x) mean(x.^2); % Mean Power
n = 100;
pn1 = pinknoise(n); % Pink Noise Vector
vp_pn1 = vp(pn1) % Mean Power Of Pink Noise Vector
vp_pn1 = 0.0014
P = 25; % Desired Pink Noise Power
k = sqrt(P / vp_pn1) % Scaling Constant
k = 134.7294
pn2 = pn1 * k; % Scaled Pink Noise Vector
vp_pn2 = vp(pn2) % Mean Power Of Scaled Pink Noise Mean Power
vp_pn2 = 25
figure
pspectrum(pn1)
title('Original')
figure
pspectrum(pn2)
title('Scaled')
EDIT — (28 August 2023 at 15:10)
To create pink noise with the same power as a particular signal, use a variation of this —
load handel.mat
filename = 'handel.wav';
audiowrite(filename,y,Fs);
clear y Fs
[y,Fs] = audioread('handel.wav')
y = 73113×1
0 -0.0062 -0.0750 -0.0312 0.0061 0.0381 0.0188 -0.0250 -0.0312 -0.0750
Fs = 8192
pn = pinknoise(numel(y))
pn = 73113×1
0.0466 0.0362 0.0269 0.0161 -0.0034 -0.0041 -0.0083 -0.0236 -0.0429 -0.0226
NewVector2 = @(OriginalSound,OriginalVector) sqrt(mean(OriginalSound.^2) ./ mean(OriginalVector.^2)) * OriginalVector;
Power_pn = mean(pn.^2)
Power_pn = 0.0011
Power_OriginalSound = mean(y.^2)
Power_OriginalSound = 0.0385
Power_NewVector = mean(NewVector2(y,pn).^2) % The Original 'pinknoise' Vector Now Has The Same Power As The Tyh Vector
Power_NewVector = 0.0385
.

更多回答(0 个)

类别

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