Entries from October 2009

October 20, 2009

How do I numerically solve an ODE in MATLAB?

The other day a student came to ask me for help in solving a second order ordinary differential equation using the ode45 routine of MATLAB.  To use ode45, one needs to be familiar with how the inputs are required by MATLAB.  The understanding of these inputs is important to use ode45 successfully in problems that [...]

October 16, 2009

The continue statement in MATLAB

The continue statement in MATLAB is used to pass control to the next iteration in for and while statements.  Let’s suppose someone wants to find and print the value of k^2-50 for all integers in [-10,10] domain.  The mfile for that is given below.
% For integers k=-10,-9,….,9,10,
% the function k^2-50 will take positive as
% well as negative values. 
%For [...]

October 13, 2009

The break statement in MATLAB

The break statement in MATLAB is used to break out of a loop – a for or while statement, that is, it terminates the execution of the loop.  Let’s suppose someone wants to find the value of k^2-50 for all integers in [-10,10] domain.  The mfile for that is given below.
% For integers k=-10,-9,….,9,10,
% the function k^2-50 [...]