How to add gaussian noise using range of variances

4 vues (au cours des 30 derniers jours)
seismo process
seismo process le 11 Sep 2020
Commenté : Ameer Hamza le 12 Sep 2020
Hii experts i want to add gaussian noise using the randn function to a data set consists of 20 columns and 500 rows.Now i want to vary the variance(in the example 1.5) from 0.0015 to 1.5 and want to save the output in output_variancevalue.txt file for each variance value in separate text file( i think for loop is required) .can anybody suggest a solution. i am new to Matlab.Thanks
A = importdata('data.ascii');
A_gaussian = A + 1.5*randn(size(A));
dlmwrite('output_1.5.txt',A_gaussian,'delimiter','\t','precision',3)

Réponses (1)

Ameer Hamza
Ameer Hamza le 11 Sep 2020
Try something like this
A = importdata('data.ascii');
var_values = logspace(log10(0.0015), log10(1.5), 10); % values of variance are taken from this vector
for i = 1:numel(var_values)
A_gaussian = A + sqrt(var_values(i))*randn(size(A));
dlmwrite(['output_' num2str(var_values(i)) '.txt'], A_gaussian,'delimiter','\t','precision',3)
end
  2 commentaires
seismo process
seismo process le 11 Sep 2020
Thanks @Ameer Hamza. however while adding the gaussian noise using the above programme the features of the image are not visible....i just need slight noise to add in this scenario what should be the var_values. does it 0.0
Ameer Hamza
Ameer Hamza le 12 Sep 2020
You may specify the var_values manually. For example,
var_values = [0.0015, 0.015, 0.15, 1.5];
By trying different values, you can see what is a good value.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating and Concatenating Matrices 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!

Translated by