summaryrefslogtreecommitdiff
path: root/macros/eqtflength.sci
blob: 505322fc4c9b70bc101e2c6a618fae0e1be279b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function [b,a,N,M] = eqtflength(b,a)
//Modifies the input vector to give output vectors of the same length
//Calling Sequence
//[b,a] = eqtflength(b,a)
//[b,a,N,M] = eqtflength(b,a)

//Author
//Debdeep Dey
    if(argn(2)~=2)
        error('Incorrect number of input arguments');
    elseif(length(a)==0|max(abs(a))==0)
        error('Division by zero not allowed');
    elseif(type(b)==10 | type(a)==10)
        b=b;
        a=a;
    else
        a=a(:).';
        b=b(:).';
        a=[a,zeros(1,max(0,length(b)-length(a)))];
        b=[b,zeros(1,max(0,length(a)-length(b)))];
        ai=find(a~=0);
        bi=find(b~=0);
        M=ai($)-1;
        if isempty(bi) then
            N=0;
        else 
            N=bi($)-1;
        end
        n=max(M+1,N+1);
        a=a(1:n);
        b=b(1:n);
    end
endfunction