summaryrefslogtreecommitdiff
path: root/iddataplot.sci
blob: 4b1818d56b530366a73a564a7100cca60c327cdc (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function iddataplot(varargin)
    [lhs rhs] = argn(0)
    if rhs <> 1 then
        error(msprintf(gettext("%s: Wrong number of input arguments."),"iddataplot"))
    end
    iddataData  =  varargin(1)
    if typeof(iddataData) <> 'iddata' then
        error(msprintf(gettext("%s:Wrong type for input argument %d: ""iddata"" expected."),"iddataplot",1))
    end
//    figure()
//    xtitle('Plant i/o Data','Time('+iddataData.TimeUnit+')','Amplitude')
    uData = iddataData.InputData
    yData = iddataData.OutputData
    timeLength = max(size(uData,'r'),size(yData,'r'))
    timeData = ((1:1:timeLength)*iddataData.Ts)'
    //timeData = timeData(1:length(iddataData)-1)
    if size(uData,'*') && size(yData,'*') then
        firstIndex = 2
    else
        firstIndex = 1
    end
    // ploting y data
    h = gcf()
    if h.figure_name == "Plant Input Output Data"; then
        clf()
    end
    if size(yData,'*') then
        secondIndex = size(yData,'c')
        if secondIndex == 1 then
            outputString = 'y'
        else
            outputString = []
            for ii = 1:secondIndex
                outputString = [outputString 'y'+string(ii)]
            end
        end
        //disp(outputString)
        for ii = 1:secondIndex
            subplot(firstIndex,secondIndex,ii);plot(timeData,yData(:,ii))
            xtitle(outputString(ii))
        end
    end
    if size(uData,'*') then
        secondIndex = size(uData,'c')
     //   disp(secondIndex)
        if secondIndex == 1 then
            outputString = 'u'
        else
            outputString = []
            for ii = 1:secondIndex
                outputString = [outputString 'u'+string(ii)]
            end
        end
        //disp(outputString)
        for ii = 1:secondIndex
            if size(yData,'*') then
                temp = 1
            else
                temp = 0
            end
            subplot(firstIndex,secondIndex,ii+secondIndex*temp);plot2d(timeData,uData(:,ii),2)
            //pause
            xtitle(outputString(ii))
        end
    end
    h = gcf()
    //disp(h)
    h.figure_name= "Plant Input Output Data";
endfunction