How to create white noise and pink noise ?
41 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I would like to know how to make pink noise and white noise.
I would also like to know how to put the created noise on the acquired tunnel current z.
I own DSP System Toolbox and Signal Processing Toolbox.
%Parameter Setting
pixel_image = 256; %Input the number of pixels in the image obtained by raster scanning (input 2^n)
dr = 1/(2*sqrt(3)); %Enter dither circle radius [grid].
a_fast_grid = 10; %fast axis scanning range [grid]
a_slow_grid = 10; %Slow axis scanning range [grid]
fm=5000; %Dither circle modulation frequency [Hz]
fs= fm * 240 ; %Sampling frequency [Hz]
f_fast = 10.2; %Input scanning frequency [Hz] (1 line scanning count in 1[s])
start_point_x = 0; %Input x-coordinate of scanning start point (input 1 if you want to move by 1[grid])
start_point_y = 0; %Input y-coordinate of scanning start point (input 1 if you want to move by 1[grid])
%Parameter setting for fast-axis triangular wave
amplitude_fast = a_fast_grid/2; %fast axis amplitude
%Parameter setting for slow-axis triangular wave
amplitude_slow = a_slow_grid/2; %slow axis amplitude
f_slow = (f_fast)/(2*pixel_image); %Slow axis triangular wave frequency
% Generation of time vectors
total_time=256/f_fast; %Total Scan Time
t = linspace(0, total_time, fs * total_time);
x_raster = start_point_x + amplitude_fast*(2/pi)*acos(cos(2*pi*f_fast*t));
y_raster = start_point_y + amplitude_slow*(2/pi)*acos(cos(2*pi*f_slow*t));
x_dither = dr*cos(2*pi*fm*t);
y_dither = dr*sin(2*pi*fm*t);
x = x_raster + x_dither;
y = y_raster + y_dither;
z1 = cos(2*pi*((x-y)/(sqrt(3))));
z2 = cos(2*pi*(2*y/(sqrt(3))));
z3 = cos(2*pi*((x+y)/(sqrt(3))));
z = (z1 + z2 + z3);
1 Commento
prabhat kumar sharma
il 24 Gen 2025
Here are a few examples that can help you.: https://www.mathworks.com/matlabcentral/fileexchange/42919-pink-red-blue-and-violet-noise-generation-with-matlab
and you can create various noise using dsp.ColoredNoise() : https://www.mathworks.com/help/dsp/ref/dsp.colorednoise-system-object.html#d126e263473
I hope it helps!
Risposta accettata
Ishaan
il 28 Gen 2025
I realise that you intend to generate noises and add them to the acquired tunnel current.
To generate noise, you can use “ColoredNoise” function from DSP System Toolbox.
To generate pink noise, you can use the following code.
pinkNoiseGenerator = dsp.ColoredNoise('Color', 'pink', 'SamplesPerFrame', length(z));
pinkNoise = pinkNoiseGenerator();
And to generate white noise you can use the “randn” function like so.
noiseAmplitude = 0.1;
whiteNoise = noiseAmplitude * randn(size(z));
Additionally, "ColoredNoise" function can be used generate white noise as well by changing the ‘Color’ parameter to ‘white’.
To add these noises to acquired tunnel current `z` value. You can use simple array addition.
z_with_white_noise = z + whiteNoise;
z_with_pink_noise = z + pinkNoise’;
NOTE: since “z” is a row vector and the noise, we generated from “ColoredNoise” function is a column vector, we would require transposing the noise vector.
You can refer to the documentation, as shared by @prabhat kumar sharma for more information on the function.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!