Sunday, May 17, 2015

MatLab code to Solve the 1st order differential equation dy/dx=3-1/x

close all;

clc;

%% Solve the 1st order differential equation dy/dx=3-1/x
%% dy/dx can be represented using 'D' or diff 
%% y(1)=1 is the initial condition 
%% if y(0) is tried then due to log factor empty system will be resulted

y=dsolve('Dy=3-1/x','y(1)=1','x')

%% Plot the expression at diffrent value of x

%% ezplot-> y is a function with respect to x
%% only plot --> x and y has some values

ezplot(y,[0 5])

No comments:

Post a Comment