summaryrefslogtreecommitdiff
path: root/Get.sci
blob: f14851a9ada1733bb2ce452e86e6733e6c885ca4 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
function []=Get(varargin)
    //disp('Get')
    tempData = varargin($)
    f = fieldnames(tempData)
//    disp(size(f,'*'))
    if ~size(f,'*') then
        if size(tempData,'*') == 0 then
            printString = 'empty'
        elseif isnan(tempData) then
            printString = 'Nan'
        elseif isinf(tempData) then
            printString = 'inf'
        else
            printString = typeof(tempData)
        end
        mprintf('The type of ""Input"" is : %s \n',printString)
        error(msprintf(gettext("%s: There is no objects in the ""Input"".\n"),"Get"))
    else
        maxLength = []
        for ii = 1:size(f,'*')
            maxLength = [maxLength length(f(ii))]
        end
        maxLength = max(maxLength)
        for ii = 1:size(f,'*')
            blanckSpace = ' '
            for jj = 1:maxLength-length(f(ii))
                blanckSpace = blanckSpace + ' '
            end
            mprintf('\t%s%s : ',blanckSpace,f(ii))
            objectData = tempData(f(ii))
            if typeof(objectData) == 'ce' then
                //mprintf('cell')
                sizeData = size(objectData)
                prodData = prod(sizeData)
                //pause
                if prodData == 1 then
                    objectData = (cell2mat(objectData))
                    objectData = getString(objectData)
                    tempString = '{' + objectData + '}'
                    mprintf('%s',tempString)
                else
                    objectData = getString(sizeData,[])
                    objectData = strsubst(objectData,']',' cell ]')
                    mprintf('%s',objectData)
                end
            elseif typeof(objectData) == 'string' then
                if length(objectData) == 0 then
                    mprintf("{''''}")
                else
                    mprintf('%s ',objectData)
                end
                
            elseif typeof(objectData) == 'constant' then
                //disp('in constant')
                //
                if ~size(objectData,'*') then
                    mprintf('%s%s','[',']')
                    //pause
                    //mprintf('%d',objectData)
                elseif size(objectData,'*') == 1 then
                    if round(objectData)-objectData == 0 then
                        mprintf('%d',objectData)
                    else
                        mprintf('%.2f',objectData)
                    end
                else
                    sizeData = size(objectData)
                    objectData = getString(sizeData,[])
                    objectData = strsubst(objectData,']',' double ]')
                    mprintf('%s',objectData)
                end
            elseif typeof(objectData) == 'polynomial' then
                if size(objectData,'*') == 1 then
                    polyData = pol2str(objectData)
                    mprintf('%s',polyData)
                else
                    objectData = size(objectData)
                    objectData = getString(objectData,[])
                    objectData = strsubst(objectData,']',' polynomial ]')
                    mprintf('%s',objectData)
                end
            elseif typeof(objectData) == 'hypermat' then
                    objectData = size(objectData)
                    objectData = getString(objectData,[])
                    objectData = strsubst(objectData,']',' hypermat  ]')
                    mprintf('%s',objectData)
            end
            mprintf('\n')
        end
    end
endfunction


// converting from matrix to string matrix
function Output = getString(varargin)
    [lhs,rhs] = argn(0)
    if rhs == 1 then
        inBetween = ' '
    elseif rhs == 2 then
        inBetween = 'x'
    end
    stringData = '['
    matData = varargin(1)
    for ii = 1 : length(matData)
        stringData = stringData + string(matData(ii)) //+ inBetween
        if ii == length(matData) then
        else
            stringData = stringData + inBetween
        end
    end
    stringData = stringData + ']'
    Output = stringData
endfunction