# How to graph sinusoid with phase angle

I am taking basic elec. circuits and I would like to know how to graph the wave forms with phase angles in either desmos, or octave or any other platform. I am not afraid of doing some coding for octave, just not sure how to go about it.
Can anyone point me in the right direction?

Thank you

• It is a bit unclear what the problem is. Is it plotting to begin with, (the manuals of different programs help with that) or adding phase to sinusoids? – Justme Oct 29 '20 at 21:30
• I know what a cos(x) and sin(x) looks like and what they look like at the 4 main pi points, But add in a phase angle and I get a little mixed up. Is there a way to graph a sine or cosine with a phase angle? – Jeff A Oct 29 '20 at 21:36
• yes sin(x + y) where y is the phase shift so sin(x + pi/6 ) – JonRB Oct 29 '20 at 21:40

## 2 Answers

Phase is added to the horizontal variable, see picture.

• I found that a few minutes ago. Does the pi/4 part always have a to be a function of pi? – Jeff A Oct 29 '20 at 21:45
• The phase can be anything, although after 2 pi it will repeat. – Mattman944 Oct 29 '20 at 21:49
• Thank you for your help, EVERYONE!! I didn't realize that the number was in radians, so when I was putting in 10 degrees, it wasn't looking right and I could not figure it out. – Jeff A Oct 29 '20 at 21:52
• @JeffA basically the trig functions are technically only valid when dealing in radians, differentiation etc doesn't work. degree's is a convinient hack because people don't like decimal places – JonRB Oct 29 '20 at 22:42

The code below show plots with phase shift of 30 degrees and works with Octave and Matlab. Although the later is not free, there is a student version. Another good option for a free scientific software package is the Scilab. Give it a try:

# Create vector: 100 points between 0 to 360 degress
x = linspace(0, 2*pi, 100);

# Phase angle in degrees
phase_deg = 30;

# Phase angle in radians
phase_rad = phase_deg/180*pi;

# Two functions
y = sin(x + phase_rad);
z = cos(x + phase_rad);

# Graph
plot(x,y,'k', x,z, 'b');

# Draw a grid, keeping the plot
grid on;
hold on;

# Draw a line in y = 0.3
plot(x, 0.3*ones(1,100), '-');

# Write a message
text(2.5, 0.7, 'plots');

# Write a legend
legend('sen(x)', 'cos()');