Many students ask me how do I do this or that in MATLAB. So I thought why not have a small series of my next few blogs do that. In this blog, I show you how to solve a boundary value ordinary differential equation.
- The MATLAB program link is here.
- The HTML version of the MATLAB program is here.
- DO NOT COPY AND PASTE THE PROGRAM BELOW BECAUSE THE SINGLE QUOTES DO NOT TRANSLATE TO THE CORRECT SINGLE QUOTES IN MATLAB EDITOR. DOWNLOAD THE MATLAB PROGRAM INSTEAD
%% HOW DO I DO THAT IN MATLAB SERIES?
% In this series, I am answering questions that students have asked
% me about MATLAB. Most of the questions relate to a mathematical
% How do I solve a boundary value ordinary differential equation?
% Language : Matlab 2008a;
% Authors : Autar Kaw;
% Mfile available at
% Last Revised : May 26, 2009;
% Abstract: This program shows you how to solve an
% boundary value ordinary differential equation.
disp(‘ This program shows you how to solve’)
disp(‘ a boundary value ordinary differential equation’)
disp(‘ Autar K Kaw of https://autarkaw.wordpress.com’)
disp(‘ May 26, 2009’)
% Solve the ordinary differential equation
% Define x as a symbol
% The initial conditions
% The value at which y is sought at
%% DISPLAYING INPUTS
func=[‘ The ODE to be solved is ‘ ode_eqn];
iv_explain=[‘ The boundary conditions are ‘ iv_1 ‘ ‘ iv_2];
fprintf(‘ The value of y is sought at x=%g’,xval)
%% THE CODE
% Finding the solution of the ordinary differential equation
% vpa below uses variable-precision arithmetic (VPA) to compute each
% element of soln to 5 decimal digits of accuracy
%% DISPLAYING OUTPUTS
output=[‘ The solution to the ODE is ‘ char(soln)];
fprintf(‘ The value of y at x=%g is %g’,xval,value)
This post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://numericalmethods.eng.usf.edu, the textbook on Numerical Methods with Applications available from the lulu storefront, and the YouTube video lectures available at http://numericalmethods.eng.usf.edu/videos and http://www.youtube.com/numericalmethodsguy
Subscribe to the blog via a reader or email to stay updated with this blog. Let the information follow you.