Effacer les filtres
Effacer les filtres

How to creat noisy copies of vector?

3 vues (au cours des 30 derniers jours)
Ihor
Ihor le 7 Déc 2022
Modifié(e) : Bora Eryilmaz le 7 Déc 2022
I should generate values of a linear function f(x) = ax + b for the x variable taking on values from the interval <-4,10> with step 0.1.
x = -4:0.1:10 ; % i did it
and to create two noisy copies: Y1, and Y2 by adding pseudo-random noise from normal distribution: one with a variance v1 = 0.1, the other with v2 = 1. How can I do that?

Réponse acceptée

Bora Eryilmaz
Bora Eryilmaz le 7 Déc 2022
Modifié(e) : Bora Eryilmaz le 7 Déc 2022
x = -4:0.1:10;
v1 = 0.1;
r1 = sqrt(v1).*randn(size(x));
Y1 = x + r1;
var(r1) % Should be approximately 0.1
ans = 0.0992
v2 = 1;
r2 = sqrt(v2).*randn(size(x));
Y2 = x + r2;
var(r2) % Should be approximately 1.0
ans = 1.0422
plot(x)
hold on
plot(Y1)
plot(Y2)

Plus de réponses (0)

Catégories

En savoir plus sur Descriptive Statistics 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