How to create sine wave with random amplitude peaks and noise
11 次查看(过去 30 天)
显示 更早的评论
Hello,
I would like to create sine wave signals with noise, phase and amplitude peak randdom.
With the code bellow I'm able to create almost want I want. I have sine waves with noise, random phase and with random amplitude. However the amplitude its random, but the same over time. How can I have random amplitudes over time between a desired internval.
Thank you
clear all
clc
nPeriods = 10;
nSamples = 200;
fSampling = 2000;
T = 40;
dt = 1 / fSampling;
t = 0:dt:T;
scaleShift = 2.2;
amplitude_mean_sin = 0.8;
amplitudeRange_min = 0.4;
amplitudeRange_max = 0.6;
phaseDeg_min = 1;
phaseDeg_max = 10;
phaseRad_min = deg2rad(phaseDeg_min);
phaseRad_max = deg2rad(phaseDeg_max);
noise_std = 0.01;
N = nSamples * nPeriods * T;
NPeriodSamples = N / nPeriods;
phaseRad_rnd = phaseRad_min * rand(1) + phaseRad_max;
ampSin = amplitudeRange_min * rand(1) + amplitudeRange_max;
noise = noise_std * (randn(1, length(t)) - 0.5);
cleanSin = scaleShift + ...
ampSin * sin(2 * pi * fSampling / NPeriodSamples * t + phaseRad_rnd);
noisy_SIN_POS = cleanSin + noise;
plot(t, noisy_SIN_POS)
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!