Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Convert Python code to Matlab code: import numpy asnp import matplotlib.pyplot as plt from scipy.integrate import odient m = 100. k = 4*np.pi**2*m eta =

Convert Python code to Matlab code:

import numpy asnp import matplotlib.pyplot as plt from scipy.integrate import odient m = 100. k = 4*np.pi**2*m eta = 5

c = np.sqrt(4*k*m/(1 + (4*np.pi/eta)**2))

zeta = 0.5*c/np.sqrt(k*m) omega_n = np.sqrt(k/m) omega_d = omega_n*np.sqrt(1-zeta**2) period = 2*np.pi/omega_d

print(c, period, zeta)

#main part, 2nd order ODE #reshape into system of 2 1st order ODEs def damp(y, t, omega_n, zeta): x, v = y dydt = [v, - omega_n**2*zeta*x - 2*zeta*omega_n*v] return dydt

#Initial conditions y0 = [0.1, 1e-5] t = np.linspace(0, 2*period, 201)

#function odeint solves system numerically sol = odeint(damp, y0, t, args = (omega_n, zeta))

#plot solution plt.figure(figsize = (10, 6))

plt.plot(t, sol[:,0], color = "blue", lw =2.)

plt.grid() plt.axhline(0, color = "k", alpha = 0.5) plt.xlabel("Time [s]", fontsize = 14) plt.ylabel("Amplitude [m]", fontsize = 14)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions