Please answer **only Question #3** and write a MatLab code. Thank you.

1. A bar with uniform cross-sectional area A, elastic modulus E, and length L is loaded with distributed loads q(r). The bar is fixed on the left end and attach to the spring of stiffness which is relaxed when the bar is undeformed A as .02㎡, the Young’s modulus E as 210 GPa (Steel ASTM A36), K = 1 000kN/m Spring constant K F(spring) Cross sectional Area: A(m2) L (m) d2u(x) B. C: u(0) = 0, F =-Ku(L) (2x)2 q0-12- x = [0, ] q (x) = do (40 points) Write a MATLAB program which Takes as input: Length of the bar, number of intervals N and q0 Assembles the FD matrices Run your program using length L-5 (unit: m), qo-5 (unit: KN), and when N=2,4,8 and N=16 2. (10 points) Find the exact solution to the problem, then plot the exact solution with FD solutions for N=2, 4, 8 and N-16 on the same plot.

## Expert Answer

3.

Syntax:

Y = RMS(X)

Y = RMS(X,DIM)

Explanation:

Y = RMS(X) returns the root-mean-square (RMS) level of the input, X. If X is a row or column vector, Y is a real-valued scalar. For matrices, Y contains the RMS levels computed along the first nonsingleton dimension. For example, if X is an *N*-by-*M* matrix with *N* > 1, Y is a 1-by-*M* row vector containing the RMS levels of the columns of X.

Y = RMS(X,DIM) computes the RMS level of X along the dimension, DIM.

t = 0:0.001:1-0.001; x = (1:4)'*cos(2*pi*100*t); y = RMS(x,2).

Or simply use this also:

RMSE = sqrt(mean((y-y_pred).^2));

Or easy to approach:

r = sqrt( sum( (data(:)-estimate(:)).^2) / numel(data) );