Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Frequency = 1000 Hz time = 0.001 sec Amplitude = 5 V I want to plot a sine wave

ID: 1862185 • Letter: F

Question

Frequency = 1000 Hz

time = 0.001 sec

Amplitude = 5 V

I want to plot a sine wave for a lab. I want the x-axis (time) to go from -0.001 to 0.001.

The following is the code I tried running:


%PLOT SINE WAVE

f_1 = 1000; %frequency in Hertz

t_1 = 0.001; %time in seconds

A_1 = 5; %amplitude in volts

t = -0.001:0.001; %time (x-axis)

X = A_1 * sin(2*pi*t_1*f_1);

%END OF CODE


I looked online and tried to plot it, but my X value is a single number and not an array. This is where I got stuck. I appreciate any help.

Explanation / Answer

HI,


You need to use t=[-0.001:.0001:.001] to plot.


The first value in the bracket is the point where you want to start from the 2nd value is the step increas you want and the last value is the final value.


So if you post [0:0.1:1] the values in the array will be 0,.1,.2,.3.....9, 1


There is one more error in your code.


X = A_1 * sin(2*pi*t_1*f_1); should be converted to X = A_1 * sin(2*pi*t*f_1);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote