How to add gaussian noise using range of variances

6 次查看(过去 30 天)
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)

回答(1 个)

Ameer Hamza
Ameer Hamza 2020-9-11
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 个评论
seismo process
seismo process 2020-9-11
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 2020-9-12
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by