how would i generate a cosine burst of frequency 2Hz, lasting 5 second in MATLAB. need the code.MATLAB coding help?
T = 5; %duration in seconds
Fs = 44100; %sampling rate
t = 1/Fs:1/Fs:T; %vector of time samples
F = 2; %frequency
signal = cos(2*pi*F*t); %create vector containing burst
plot(t, signal); xlabel('time, sec'), ylabel('cos(t)'); %plot it
soundsc(signal, Fs); %play it through your soundcard
You may want to apply a window too, depending on what you're doing. That's reasonably easy - something like this should do the trick:
signal = hamming(length(t)).' .* cos(2*pi*F*t);MATLAB coding help?
n=0:5T;
T= ??; -- you need to define the sampling rate like say 64
f=2;
w=2*pi*f/T;
X= cos(w*n);
i imagine you'll want a plot so:
plot(n,X)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment