In: Mechanical Engineering
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
Copyable code is :
func = @(x,y) -x^2+((x^3*2.7183^-y)/4);
%using the ode45 built in solver, initial condition y(1)=1 with
interval [1, 5]
[xValue,yValue] = ode45(func,[1,5],1);
fprintf('The points of calculation are :\n')
%for 2-digits precision
fprintf('%.2f, %.2f\n',xValue, yValue)
%plotting the graph with solid red line
plot(xValue,yValue,'r-')