import numpy as np
import scipy.linalg as la
import matplotlib.pyplot as plt
5. Use the np.linspace function to create a row vector called meshPoints
containing exactly 500 values with values evenly spaced between -1 and 1.
6. What expression will yield the value of the 53th element of meshPoints?
What is this value?
7. Produce a plot of a sinusoid on the interval [−1, 1] using the command
plt.plot(meshPoints,np.sin(2*pi*meshPoints))
import math
import numpy as np
import scipy.linalg as la
import matplotlib.pyplot as plot
meshPoints = np.linspace(-1,1,500)
print('Answer to the 5 question: \n', meshPoints)
print('Answer to the 6 question: \n', meshPoints[52])
print('Answer to the 7 question: \n')
plot.plot(meshPoints,np.sin(2*math.pi*meshPoints))
# Give a title for the sine wave plot
plot.title('Sine wave')
# Give x axis label for the sine wave plot
plot.xlabel('Time')
# Give y axis label for the sine wave plot
plot.ylabel('Amplitude = sin(time)')
plot.grid(True, which='both')
plot.axhline(y=0, color='k')
plot.show()
# Display the sine wave
plot.show()
Comments
Leave a comment