Chapter 5

Chapter 5 Code Examples

MATLAB Code Examples

 

Python Code Examples

Exercises

  1. Make two separate plots of the function
    f(x)=0.01x^4-0.45x^2+0.5x-2
    one for -4\leqx\leq4\) and one for -8\leqx\leq8\)
  2. Plot the function
    f(x) = \frac{x^2-4x-5}{x-2}
    Notice that the function has a vertical asymptote at x=2. Plot the function by creating two vectors for the domain of x, the first vector with elements from -4 to 1.7, and the second vector with elements from 2.3 to 8. For each x vector, create a y vector with the corresponding values of y according to the function. To plot the function make two curves in the same plot.
  3. You have an electrical circuit that includes a voltage source vs with an internal resistance rs and a load resistance R_L. The power P dissipated in the load is given by:
    P = \frac{v_s^2R_L}{(R_L+r_s)^2}
    Plot the power P as a function of R_L for 1\Omega\leq$ R_L \leq10\Omega\) given that v_x = 12V and r_s = 2.5\Omega
  4. The Gateway Arch in St. Louis is shaped according to the equation:
    y=693.8-68.8\cosh(\frac{x}{99.7})
    Make a plot of the arch. Draw a horizontal line at ground level (y=0),
    x=\pm 99.7 \arccos (\frac{693.8}{68.8})
  5. In astronomy, the relationship between the relative temperature T/T\textsubscript{SUN} (temperature relative to the sun), relative luminosity L/L\textsubscript{SUN} and relative radius R/R\textsubsript{SUN} of a star is modeled by:
    \frac{L}{L\textsubscript{SUN}} = (\frac{R}{R\textsubscript{SUN}})^2 (\frac{T}{T\textsubscript{SUN}})^4
    The HR (Hertzsprung-Russell) diagram is a plot of L/L\textsubscript{SUN} versus the temperature. The following data are given:

    Sun Spica Regulus Alioth Barndard’sStar Epsilon Indi Beta Crucis
    Temp (K) 5840 22400 13260 9400 3130 4280 28200
    L/L\textsubscript{SUN} 1 13400 150 108 0 0.15 43000
    R/R\textsubscript{SUN} 1 7.8 3.5 3.7 0.18 0.76 8

    To compare the data with the model, plot a HR diagram. The diagram should have two sets of points. One uses the values of L/L\textsubscript{SUN} from the table (use asterisk markers), and the other uses values of L/L\textsubscript{SUN} that are calculated by the equation using R/R\textsubscript{SUN} from the table (use circle markers). In the HR diagram both axes are logarithmic. In addition, the values of the temperature on the horizontal axis are decreasing from left to right. Label the axes and use a legend. (See https://en.wikipedia.org/wiki/Hertzsprung%E2%80%93Russell_diagram for a general explanation of the HR diagram.)

  6. The position x as a function of time that a particle moves along a straight line is given by:
    x(t) = -0.1t^4 +0.8t^3 +10t -70
    The velocity v(t) is determined by the derivative of x(t) with respect to t, and the acceleration a(t) is determined by the derivative of v(t) with respect to t.
    Derive the expressions for the velocity and acceleration of the particle, and make plots for the position, velocity, and acceleration as a function of time for 0\leqt\leq8\) Time t is measured in seconds, and position x is measured in meters. Make three plots, one for position, one for velocity, and one for acceleration. Label the axes appropriately with correct units.
  7. A resistor, R=2\Omega and an inductor, L=1.7H are connected to a voltage source in series (RL circuit). When the voltage source applies a rectangular voltage pulse with an amplitude of V=24V and a duration of 0.5s, the current i(t) in the circuit as a function of time is given by:
    i(t) = (\frac{V}{R}) (1 - e^\frac{-Rt}{L}) for 0\leqt\leq0.5\)
    i(t) = e^\frac{-Rt}{L}(\frac{V}{R})e^\frac{0.5R}{L} for 0.5\leqt
    Make a plot of the current as a function of time for 0\leqt\leq5\) seconds.
Skip to toolbar