Month: July 2018

Linearize nonlinear state space equation in MATLAB at steady state setpoint

This post shows one way to linearize a nonlinear state equation \dot{x} = f(x,u) at a steady state setpoint (x_0, u_0) in MATLAB. It is assumed that a function ode.m exists in which the state equation is implemented:

function dx = ode(t, x, u)
    % example ODE
    dx1 = tan(x(4)) * x(2) + 2*u(2) - 1;
    dx2 = x(1) - sin(x(2));
    dx3 = 13 * x(4) + u(1) + 1;
    dx4 = 2*x(1);

    dx = [dx1; dx2; dx3; dx4];

Read More

Calculate Levenshtein distance in MATLAB (words or characters) with Wagner–Fischer algorithm

This is a MATLAB implementation of the Wagner–Fischer algorithm.

Read More