Question

In: Mechanical Engineering

Show to use ode45 built-in function in MATLAB to solve the following ODE problem: dydx=x^2 /...

Show to use ode45 built-in function in MATLAB to solve the following ODE problem:

dydx=x^2 / y y(0)=2  

Calculate y(x) for 0 ? x ? 20 and compare the results to analytical solution y = sqrt((2x^3 / 3) + 4)

Solutions

Expert Solution

The Matlab code is given below:

Matlab Code:

%Start of code
xfinal = 20; % Final value of x
xspan = [0 xfinal];
y0 = 2; % Initial value of y
F = @(x,y) (x^2/y); % Differential function
[X,Y] = ode45(F,xspan,y0); % Solve the equation

%Results at specified vlaues of x
Y0 = Y(X == 0)
Y0_analytical = ((2*0.^3/3)+4).^0.5
Y20 = Y(X == 20)
Y20_analytical = ((2*20.^3/3)+4).^0.5

% Plot both the solutions
plot(X,Y,'.')
hold on
plot(X,((2*X.^3/3)+4).^0.5,'r')
xlabel('X')
ylabel('Y')
legend('ode45','analytical solution'
% End of code

As it can be noticed, the solution obtained using ode45 is close to the analytical solution


Related Solutions

2. Use MATLAB (ode45) to solve the second-order Euler-Cauchy ODE given in the thick-walled tube elasticity...
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.
solve an ODE of whatever expression using ode45 in matlab obtaining the result [t,y]. Evaluate the...
solve an ODE of whatever expression using ode45 in matlab obtaining the result [t,y]. Evaluate the solved ODE in a point. Everything should be done in matlab.
Implement the Lorenz-63 model in MATLAB, and solve numerically (using MATLAB’s ode45 or other built-in solver)...
Implement the Lorenz-63 model in MATLAB, and solve numerically (using MATLAB’s ode45 or other built-in solver) for any random, non-zero initial conditions to reproduce, qualitatively, Figures 3 and 4. Note that, as usual, you should label your axes and make the plots as “pretty” as possible. The model equations are dx/ dt = σ(y − x), dy /dt= x(ρ−z)−y, dz/dt = xy − βz. Use parameter values σ = 10, ρ = 28, and β = 8/3.
Use MATLAB to solve the following problem: x - 3y = 2 x + 5y = 18 4x - 6y = 20
Use MATLAB to solve the following problem:x - 3y = 2x + 5y = 184x - 6y = 20  
use a matlab built-in function to numerically solve: dy/dx= -x^2+((x^3*e^-y)/4) for 1<=x<=5 with y(1)=1 plot the...
use a matlab built-in function to numerically solve: dy/dx= -x^2+((x^3*e^-y)/4) for 1<=x<=5 with y(1)=1 plot the solution
Use MATLAB DSOLVE to solve the folloing ODE and plot it: 300x'' + 60x' + 6840...
Use MATLAB DSOLVE to solve the folloing ODE and plot it: 300x'' + 60x' + 6840 = f(t)
IN MATLAB, Create a 8x8 magic matrix. Then use MATLAB built in function, sum, to calculate...
IN MATLAB, Create a 8x8 magic matrix. Then use MATLAB built in function, sum, to calculate the sum of each column. Use subscript notation to find the 6th element and the last element of each magic square. Find the maximum of all the elements in each magic square.
solve using both methods (Dsolve and ODE45 on matlab) please provide steps 1) y'+y=e^x 2) y'+2y=...
solve using both methods (Dsolve and ODE45 on matlab) please provide steps 1) y'+y=e^x 2) y'+2y= 2 sin(x)
Use Laplace transformations to solve the following ODE for x(t): x¨(t) + 2x(t) = u˙(t) +...
Use Laplace transformations to solve the following ODE for x(t): x¨(t) + 2x(t) = u˙(t) + 3u(t) u(t) = e^−t Initial conditions x(0) = 1, x˙(0) = 0, u(0) = 0
Please solve the following problem for MATLAB Write a user-defined function that calculates the average and...
Please solve the following problem for MATLAB Write a user-defined function that calculates the average and the standard deviation of a list of numbers. Use the function to calculate the average and the standard deviation of the following list of grades : 80 75 91 60 79 89 65 80 95 50 81
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT