From: Paul on 27 May 2010 12:48 Hi, I have to create a sine wave with an amplitude of 1, frequency of 10 kHz for a period of 0.2 sec. Using a sampling frequency of 20 kHz. i have the following (which I think should work): t=[0:1/20000:0.2]; A=1; f=10000; y=A*sin(2*pi*f*t); plot(t,y) but the figure looks bad, can someone tell me what I do wrong? with kind regards
From: Wayne King on 27 May 2010 13:05 "Paul " <pvankaam86(a)hotmail.com> wrote in message <htm7op$ss3$1(a)fred.mathworks.com>... > Hi, > > I have to create a sine wave with an amplitude of 1, frequency of 10 kHz for a period of 0.2 sec. Using a sampling frequency of 20 kHz. > > i have the following (which I think should work): > t=[0:1/20000:0.2]; > A=1; > f=10000; > y=A*sin(2*pi*f*t); > plot(t,y) > > but the figure looks bad, can someone tell me what I do wrong? > > with kind regards Hi, increase your sampling rate (decrease your sampling interval) t = [0:1/30000:0.2]; A = 1; f =10000; y = A*sin(2*pi*f*t); plot(t(1:100),y(1:100)) Wayne
From: David Young on 27 May 2010 13:07 It looks OK to me. You expect y to be zero everywhere, and so it is, apart from some arithmetic rounding errors. (If you sample a pure 10kHz signal at 20kHz, and you start at 0 phase, you sample the zero-crossings.) If you want to sample the signal at its peaks and troughs, you could change the phase by pi/2.
|
Pages: 1 Prev: ssSetSampleTime()/ssGetSampleTime() in C-MEX s-function Next: Operating on a large 5D dataset |