找到你要的答案

Q:Plotting sine wave in MATLAB

Q:在MATLAB中绘制正弦波

I need to plot a sine wave of analog frequency of 8Hz, with a sampling rate of 5000/sec and a duration of 5 seconds. Is this the correct way of how to do it?

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

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

   figure;
   plot(t,x);

I need to plot a sine wave of analog frequency of 8Hz, with a sampling rate of 5000/sec and a duration of 5 seconds. Is this the correct way of how to do it?

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

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

   figure;
   plot(t,x);
answer1: 回答1:

The sin wave is given by

So The correct code is

 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);

And the sin wave Matlab plot is here Result of the code

罪恶波是由

所以正确的代码是

 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);

And the sin wave Matlab plot is here Result of the code

matlab  sine