2015-05-02 252 views
0

我需要繪製8Hz模擬頻率的正弦波,採樣率爲5000 /秒,持續時間爲5秒。 這是如何做到這一點的正確方法?在MATLAB中繪製正弦波

Fs = 5000;     
    dt = 1/Fs;     
    t = 0: dt: 5; 

    Fc = 8;     
    x = sin(2*pi*Fc*t); 

    figure; 
    plot(t,x); 
+1

是的,這是完善。但是這個網站更多的是幫助那些有特定編程問題的人,而不是真正的驗證一些(_home_)的作品。 – Hoki

回答

0

罪波被

Sin Wave

給出所以正確的代碼

Fs = 5000; % This is the sample rate, in Hz.    
dt = 1/Fs;  
t = 1:dt: 1000; 
Fc = 8; % This is the frequency, in Hz, of the sinewave.     
x = sin(2*pi*Fc/Fs*t); 
t=t/Fs; % This creates the time line, in seconds, for the display.  
plot(t,x); 

贖罪波Matlab的情節在這裏 Result of the code

+1

什麼是'FS',你爲什麼用'FS'和'Fs'除? – mbschenkel