how to add noise for integral solution

3 views (last 30 days)
Mihail Georgiev
Mihail Georgiev on 10 Jun 2015
Commented: Walter Roberson on 11 Jun 2015
Dear Matlab associates, Dear Matlab users,
I would like to add noise to check how the integral solves for simulation purposes.
Example given:
A = 1;
t1 = 100;
fun = @(x)(A+sin(x));
q = integral(fun,0,t1);
In the example above I would like to add a noise to the sinusoidal signal A+sin(x) (e.g.) and check the result of the integral.
BR,
Mihail

Answers (1)

Walter Roberson
Walter Roberson on 11 Jun 2015
Constant noise, or noise that might differ between calls?
Constant noise:
An = A + randn();
fun = @(x)(An+sin(x));
Noise that might vary as it goes:
fun = @(x)(A+sin(x)+randn(size(x)));
this would use constant noise for any one call but the noise would differ between calls. Note: I coded the routine to work with ArrayValued in case you wanted to use that.
Noise that varies across calls is effectively a discontinuity in the function and you could expect difficulty in integration.
  2 Comments
Mihail Georgiev
Mihail Georgiev on 11 Jun 2015
Oh wow, Mr. Robertson. I think case is closed. It makes sense, since I need gaussian constant noise, and the noise should vary between calls(which is practical case). Actually, for those who might look for the same case. It could be solved numerically by trapz method if high enough sampling frequency is provided. Case solved.
Walter Roberson
Walter Roberson on 11 Jun 2015
The biggest difference between the two is what would happen if the function were called twice for the same x. In the first version I gave, the two calls would return the same value. In the second version I gave, the two calls would return different values.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!