I need to simulate a sensor sending data in order to test my algorithm. How can I do this in MATLAB? For example, say I create a noisy sine wave like this:
t = [0:1:1000];
vn = .2;
f = .5;
fs = 50;
x = 4*sin(2*pi*f/fs*t) + vn*rand(size(t));
x is simulation data only, where f is the frequency of the signal and fs is the sampling frequency. I would like to get one element of x every .02 seconds, or 50 Hz, into a function I have defined. So, when my function starts I would get x(1), then at 0.02 seconds later I would get x(2) and so on...
I really appreciate any help you can provide.