Skip to content

Instantly share code, notes, and snippets.

@flare9x
Created May 18, 2023 05:19
Show Gist options
  • Save flare9x/af7a40327786ab13662e7470c8812266 to your computer and use it in GitHub Desktop.
Save flare9x/af7a40327786ab13662e7470c8812266 to your computer and use it in GitHub Desktop.
sine and cosine
# julia language
using Plots
# n = degrees
n = 360
sin_out = fill(NaN,n)
cos_out = fill(NaN,n)
for i = 1:size(sin_out,1)
# julia function - sind,cosd = sin/cos in degrees
sin_out[i] = sind(i)
cos_out[i] = cosd(i)
end
# plot
p1 = plot(sin_out, title="sin degrees")
p2 = plot(cos_out, title="cos degrees")
# plot in a pane
all_out = plot(p1, p2, layout = (2, 1), size=(800,800),legend = false)
# extend the series by a multiple of circle rotations
# multiplier
mult = 5
# n = degrees
n = 360*mult
sin_out = fill(NaN,n)
cos_out = fill(NaN,n)
for i = 1:size(sin_out,1)
# julia function - sind,cosd = sin/cos in degrees
sin_out[i] = sind(i)
cos_out[i] = cosd(i)
end
# plot
p1 = plot(sin_out, title="sin degrees")
p2 = plot(cos_out, title="cos degrees")
# plot in a pane
all_out = plot(p1, p2, layout = (2, 1), size=(800,800), legend = false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment