find the order of a differential equation in matlab

To find the order of a differential equation in Matlab, you can use the odeorder function. This function takes two inputs: the function handle defining the differential equation and the independent variable. Here's an example:

main.m
% Define the differential equation
y = sym('y(x)');
eqn = diff(y,2) + 3*diff(y) + 2*y == 0;

% Find the order of the differential equation
order = odeorder(eqn, 'x')
166 chars
7 lines

In this example, we first define the differential equation using the symbolic math toolbox in Matlab. Then we use the odeorder function to find the order of the differential equation with respect to the independent variable 'x'.

Note that the odeorder function only works with linear differential equations. If your differential equation is nonlinear, you'll need to manually find the order of the highest derivative.

gistlibby LogSnag