EE341.01: MATLAB SESSION FOR PLOTTING A SINE WAVEFORM

This example shows how MATLAB commands can be typed at the MATLAB prompt to plot a sine wave. Note that the diary file 'e1_diary' was used to store the commands typed as well as the MATLAB responses.

Commands Typed and MATLAB Responses:

>> diary e1_diary
>> amp = 3

amp =

     3

>> freq_HZ = 5;
>> freq_RPS = 2*pi*freq_HZ;
>> t = 0:0.005:0.5;
>> y = amp * sin(freq_RPS * t);
>> plot(t,y)
>> xlabel('Time (seconds)')
>> ylabel('y(t)')
>> title('EE341.01    Example 1 Plot')
>> grid
>> diary off

Resulting e1_diary Diary File:

>> amp = 3

amp =

     3

>> freq_HZ = 5;
>> freq_RPS = 2*pi*freq_HZ;
>> t = 0:0.005:0.5;
>> y = amp * sin(freq_RPS * t);
>> plot(t,y)
>> xlabel('Time (seconds)')
>> ylabel('y(t)')
>> title('EE341.01    Example 1 Plot')
>> grid
>> diary off

MATLAB Plot Generated:

The plot was printed by typing 'print' at the MATLAB prompt when the plot was displayed in the graphics window.