solving Diophantine equation

by

 

12 Nov 2012 (Updated )

This function is written to solve Diopantine equation.this equation should be in the form of C = A*F

dioph_SISO(A,C,n)
 % This function is written to solve Diophantine equation.
 % this equation should be in the form of C = A*E + F 
 % where C and A are the polynomials according to your variable (for 
 % example s in laplace domain or z in z-transform domain) and n is the
 % order E plus one (order{E} = n-1).
 % please contact me for any question or suggestion.
 
%          **************************************************
%            *    Author name : Davood (David) Shaghaghi  *
%            *          davood.shaghaghi@gmail.com        *
%            *         KNT University of Technology       *
%            *               7 November 2012              *
%          **************************************************

function [E,F] = dioph_SISO(A,C,n)
F = cell(n,1);
E = cell(n,1);
E{1} = C(1)/A(1);
F{1} = [C zeros(1,length(A)-length(C))] - E{1} * A;
F{1} = [F{1}(2:end) 0];
for i=2:n
    E{i} = F{i-1}(1)/A(1);
    F{i} = F{i-1} - E{i} * A;
    F{i} = [F{i}(2:end) 0];
end
EE = cell(n,1);
for i=1:n-1
%     EE{i} = [E{1:i} zeros(1,n-i)];
EE{i} = [E{1:i}];
    F{i}(end) = [];
end
EE{n} = [E{1:n}];
F{n}(end) = [];
% F = cell2mat(F);
E = EE;
end

Contact us