Creating a Signal Vector with Given Conditions
1 view (last 30 days)
Show older comments
I'm required to create the following signal in MATLAB with sampling rate of 1000 samples per second and with 200 samples.
X = sin(50*pi*t) + 2*sin(100*pi*t)
I have done this as follows
-----------------------------------------------------------------
Fs = 1000; %Sampling Rate
N = 200; %Number of Samples
n = 0:N-1 %Numbering the Samples
x = sin(50*pi*Fs*n/N) + 2*sin(100*pi*Fs*n/N);
plot (x)
------------------------------------------------------------------
and
------------------------------------------------------------------
Fs = 1000; %Sampling Rate
N = 200; %Number of Samples
t = 0:N/Fs:N-1 %Sampling Time
x = sin(50*pi*t) + 2*sin(100*pi*t);
plot (x)
-------------------------------------------------------------------
However, both these plots are different from each other. Can someone explain why they are different please ?
0 Comments
Answers (1)
Image Analyst
on 9 May 2015
Hint: Look at what your time variable is in each of the cases, and especially if the delta t between adjacent time elements makes sense given the sampling rate. Try to put the first term into the standard form sin(2*pi*omega*t) and see what omega (the frequency) is. Also note that sampling rate is independent of the frequency (or period).
You might want to use linspace() instead.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!