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

  • \$\begingroup\$ 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? \$\endgroup\$ – Justme Oct 29 '20 at 21:30
  • \$\begingroup\$ 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? \$\endgroup\$ – Jeff A Oct 29 '20 at 21:36
  • 1
    \$\begingroup\$ yes sin(x + y) where y is the phase shift so sin(x + pi/6 ) \$\endgroup\$ – JonRB Oct 29 '20 at 21:40

Phase is added to the horizontal variable, see picture.

enter image description here

  • \$\begingroup\$ I found that a few minutes ago. Does the pi/4 part always have a to be a function of pi? \$\endgroup\$ – Jeff A Oct 29 '20 at 21:45
  • \$\begingroup\$ The phase can be anything, although after 2 pi it will repeat. \$\endgroup\$ – Mattman944 Oct 29 '20 at 21:49
  • \$\begingroup\$ 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. \$\endgroup\$ – Jeff A Oct 29 '20 at 21:52
  • \$\begingroup\$ @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 \$\endgroup\$ – 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()');

sin() amd cos() with phase shifts


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.