Make a matrix which has dimension [0.04:0.01:0.53] as first column, the volume Vsphere = as second column, volume Vcube = as the third column, the difference = (Vsphere Vcube) as the fourth column. Make a plot between Vsphere and L, Vcube and L, and difference and L. Note: You must use for loop
import numpy as np
import matplotlib.pyplot as plt
import math
matrix=np.zeros([3,4])
matrix[:,0]=[0.04,0.01,0.53]
for i in range(3):
matrix[i,1]=(3*math.pi*(matrix[i,0]**3))/4
matrix[i,2]=matrix[i,0]**3
matrix[i,3]=matrix[i,1]-matrix[i,2]
print(matrix)
for i in range (3):
temp=131+i
plt.subplot(temp)
plt.scatter(matrix[:,0],matrix[:,i],label= "stars", color= "green",marker= "*", s=30)
plt.xlabel('dimensions')
plt.ylabel('result')
plt.legend()
plt.show( )
Get Answers For Free
Most questions answered within 1 hours.