Personal Website:
Scott Congreve

Teaching

Download<< Back

function pts = mstep_stab(a, b, linespec)
%MSTEP_STAB Plots the domain of stability for specified m-step method
% using the specified linespec
%
% Parameters:
%          a - Vector of 'a' coefficients of the m-step methods in order a_m, a_{m-1}, ..., a_0
%          b - Vector of 'b' coefficients of the m-step methods in order b_m, b_{m-1}, ..., b_0
%   linespec - Line spec to use to plot the domain
%
% Note: a and b must be the same length; e.g. first entry of b must be 0 for explicit methods

if length(a) ~= length(b)
    error("Length of coefficient vectors a and b must be same")
end
z = exp(pi*(0:360)*1j/180).'';
pts = (polyval(a,z)./polyval(b,z));
plot(pts, linespec);