EE5003 Final Exam – Fall 2020

 

Question 1: ESSAY

Using the default settings in ode45, write MATLAB® scripts that will solve the following differential equation:

for a frequency (f) of 1 Hz.  Also, since the solution of this trivial differential equation is:

include in your main script  the code needed to plot out the theoretical solution along with the numerical solution.

MATLAB® help for “ode45”:

ode45  Solve non-stiff differential equations, medium order method.

[TOUT,YOUT] = ode45(ODEFUN,TSPAN,Y0) with TSPAN = [T0 TFINAL] integrates the system of differential equations y’ = f(t,y) from time T0 to TFINAL with initial conditions Y0. ODEFUN is a function handle. For a scalar T and a vector Y, ODEFUN(T,Y) must return a column vector corresponding to f(t,y). Each row in the solution array YOUT corresponds to a time returned in the column vector TOUT.  To obtain solutions at specific times T0,T1,…,TFINAL (all increasing or all decreasing), use TSPAN = [T0 T1 … TFINAL].

 

 

 

 

 

 

 

 

 

Question 2:  ESSAY

Write the sequence of MATLAB® commands needed to find, symbolically, the indefinite integral of the following function:

Then write a MATLAB® script that numerically integrates this function (dy/dt) from t_start to t_stop for f = 1.

MATLAB® help for “integral”:

integral  Numerically evaluate integral.

Q = integral(FUN,A,B) approximates the integral of function FUN from A to B using global adaptive quadrature and default error tolerances.

FUN must be a function handle. A and B can be -Inf or Inf. If both are finite, they can be complex. If at least one is complex, integral approximates the path integral from A to B over a straight line path.

For scalar-valued problems the function Y = FUN(X) must accept a vector argument X and return a vector result Y, the integrand function evaluated at each element of X.

 

 

 

 

 

 

 

 

 

 

 

 

 

QUESTION 3:   ESSAY

Write a MATLAB® script that plots a segment of a sphere using blue dots, and computes the area of the segment. The segment is R=7, theta=20:60, and phi=25:50. The following formulas may be useful:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

QUESTION 4:   ESSAY

Assume the matrix ‘A’ has been defined in MATLAB® and consists of three columns. The first column consists of the times at which voltage across and current through a resistor were measured. The second column consists of the voltage measurements. The third column consists of the current measurements.

Write the MATLAB® commands needed to create a structure named ‘r_meas’ with the fields ‘time’, ‘voltage’ and ‘current’ populated with the data from matrix A.