Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
plotting of graphs
#1
I have an assignment where i have plot two physics equations named them as x and why,
The only unkown is the angle, so i made a loop for the possible angles between 0 and 360
import math
import numpy
import matplotlib.pyplot as plt
l= 1.5  
m= 2.5   
g= 9.81 
d= 2.7 
k= 9.08
alpha = 0
while (alpha<360):
    alpha = alpha + 1
    angles = math.radians(alpha)
    x = 1-((2*l)/d)*math.sin(angles)
    y = ((m*g)/(k*d))*math.tan(angles)
    plt.plot(x,y)
    plt.show()
My question is how do i plot the two equations without knowing the value of theta?
Is there anything wrong with my code?
snippsat wrote Feb-09-2019, 06:58 PM:
Added code tag in your post,look at BBCode on how to use.
Quote
#2
(Feb-09-2019, 06:32 PM)mudezda1 Wrote: My question is how do i plot the two equations without knowing the value of theta?
I didn't see the value of theta...

(Feb-09-2019, 06:32 PM)mudezda1 Wrote: Is there anything wrong with my code?
You don't need math at all, since you are importing numpy. Also, you don't need to use loops.
You need to create arrays of x- and y-values and plot the parametric graph.

import numpy as np
import matplotlib.pyplot as plt

# define your constants here... 

angles = np.arange(360) / 180 * np.pi # step is one degree
x = 1 - ((2 * l) / d) * np.sin(angles)
y = ((m * g) / (k * d)) * np.tan(angles)
plt.plot(x, y)
plt.show()
Quote
#3
(Feb-10-2019, 04:32 AM)scidam Wrote:
(Feb-09-2019, 06:32 PM)mudezda1 Wrote: My question is how do i plot the two equations without knowing the value of theta?
I didn't see the value of theta...
(Feb-09-2019, 06:32 PM)mudezda1 Wrote: Is there anything wrong with my code?
You don't need math at all, since you are importing numpy. Also, you don't need to use loops. You need to create arrays of x- and y-values and plot the parametric graph.
import numpy as np import matplotlib.pyplot as plt # define your constants here... angles = np.arange(360) / 180 * np.pi # step is one degree x = 1 - ((2 * l) / d) * np.sin(angles) y = ((m * g) / (k * d)) * np.tan(angles) plt.plot(x, y) plt.show()
I sincerely thank you for your help.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Frequency Filter for wav file plotting in python manukanu 0 208 Dec-11-2018, 09:58 AM
Last Post: manukanu
  Plotting climate data with NetCdf files for a specific region with coordinates fyec 3 464 Jun-27-2018, 12:34 PM
Last Post: buran
  Plotting Graph jacky19971997 0 1,047 Jun-11-2017, 02:54 PM
Last Post: jacky19971997
  mcerp: error while plotting a histogram rakhmadiev 2 1,542 Apr-02-2017, 09:08 PM
Last Post: rakhmadiev
  Tuple Unpacking with graphs in matplotlib smw10c 2 1,602 Mar-23-2017, 05:13 PM
Last Post: smw10c
  plotting histogram vvv 1 1,042 Mar-10-2017, 11:47 PM
Last Post: zivoni
  Issue plotting coordinates using Basemap kiton 5 3,509 Mar-09-2017, 07:33 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)