Pink noise with specific power P
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponse acceptée
Star Strider
le 26 Août 2023
Modifié(e) : Star Strider
le 28 Août 2023
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
P = 25; % Desired Pink Noise Power
k = sqrt(P / vp_pn1) % Scaling Constant
pn2 = pn1 * k; % Scaled Pink Noise Vector
vp_pn2 = vp(pn2) % Mean Power Of Scaled Pink Noise Mean Power
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')
pn = pinknoise(numel(y))
NewVector2 = @(OriginalSound,OriginalVector) sqrt(mean(OriginalSound.^2) ./ mean(OriginalVector.^2)) * OriginalVector;
Power_pn = mean(pn.^2)
Power_OriginalSound = mean(y.^2)
Power_NewVector = mean(NewVector2(y,pn).^2) % The Original 'pinknoise' Vector Now Has The Same Power As The Tyh Vector
.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spectral Measurements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!