In: Computer Science
2. Use MATLAB (ode45) to solve the second-order Euler-Cauchy ODE given in the thick-walled tube elasticity problem handout for the case:
?r(1) = 0.1, dur(1)/dr = −0.02
Have your MATLAB code print out the values for the constants you determined in the general solution; i.e. “C1 = ... , C2 = ...” make a comparison plot showing your exact solution and the numerical MATLAB result on the same axes.
Here is the solution. Please do upvote thank you.
Code:
clear all
close all
clc
r=[1:0.5:25];
u0=[0.1-0.02];
[r,u]=ode45(@(r,u) Euler_Cauchy(r, u), r, u0) ;
plot(r, u(:, 1))
axis([1,25 min(u(:, 1)) max(u:, 1))])
xlabel('r');
ylabel('u(r)');
Code 2:
function [udot]=Euler_Cauchy(r, u) ;
udot(1)=u(2);
udot(2)=-(u(2).r+2*u(1).r/.^2);
udot=udot'
end