How to add gaussian noise using range of variances

조회 수: 6 (최근 30일)
seismo process
seismo process 2020년 9월 11일
댓글: Ameer Hamza 2020년 9월 12일
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