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)
댓글 수: 0
답변 (1개)
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
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 Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!