Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LRT_infinite_dimensional_systems
conI
Commits
063c062e
Commit
063c062e
authored
Sep 30, 2020
by
Jakob Gabriel
Browse files
misc.ss.Odes: some fixes
parent
ac3443b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
+misc/+ss/Odes.m
View file @
063c062e
...
...
@@ -35,7 +35,7 @@ classdef Odes < handle & matlab.mixin.Copyable
obj
.
type
=
type
;
for
it
=
1
:
numel
(
stateSpaces
)
[
obj
.
ss
{
it
},
obj
.
C
{
it
},
obj
.
D
{
it
}]
...
=
obj
.
sep
e
rateOutputfromSs
(
stateSpaces
{
it
},
type
{
it
});
=
obj
.
sep
a
rateOutputfromSs
(
stateSpaces
{
it
},
type
{
it
});
end
% for it = 1 : numel(stateSpaces)
obj
.
verifyProperties
();
end
% if nargin > 0
...
...
@@ -83,7 +83,7 @@ classdef Odes < handle & matlab.mixin.Copyable
% Ode = misc.ss.Odes(ss1, 'ss1');
% Ode.exchange('ss1', ss2)
[
obj
.
ss
{
obj
.
index
(
myType
)},
obj
.
C
{
obj
.
index
(
myType
)},
obj
.
D
{
obj
.
index
(
myType
)}]
...
=
obj
.
sep
e
rateOutputfromSs
(
newSs
,
myType
);
=
obj
.
sep
a
rateOutputfromSs
(
newSs
,
myType
);
obj
.
verifyProperties
();
end
% exchange()
...
...
@@ -257,53 +257,55 @@ classdef Odes < handle & matlab.mixin.Copyable
obj
misc
.
ss
.
Odes
;
NameValue
.
stateName
string
=
"v"
;
end
% prepare signal names
thisOutputName
=
string
(
misc
.
ss
.
removeEnumeration
(
obj
.
OutputName
,
true
));
thisOutputName
=
thisOutputName
.
extractBefore
(
2
)
+
"_{"
...
+
thisOutputName
.
extractAfter
(
1
)
+
"}(t)"
;
thisInputName
=
string
(
misc
.
ss
.
removeEnumeration
(
obj
.
InputName
,
true
));
thisInputName
=
thisInputName
.
extractBefore
(
2
)
+
"_{"
...
+
thisInputName
.
extractAfter
(
1
)
+
"}(t)"
;
assert
((
numel
(
obj
.
ss
{
1
})
==
1
)
&&
(
numel
(
thisOutputName
)
==
1
)
...
&&
(
numel
(
thisInputName
)
==
1
),
"yet only implemented for misc.ss.Odes with "
...
+
" 1 ss, 1 OutputName, 1 InputName"
);
myOdeString
=
"\dot{"
+
NameValue
.
stateName
.
extractBefore
(
2
)
+
"}"
...
+
"_{"
+
NameValue
.
stateName
.
extractAfter
(
1
)
+
"}(t) &= "
;
if
strlength
(
NameValue
.
stateName
)
>
1
myOdeString
=
"\dot{"
+
NameValue
.
stateName
.
extractBefore
(
2
)
+
"}"
...
+
"_{"
+
NameValue
.
stateName
.
extractAfter
(
1
)
+
"}(t) &= "
;
NameValue
.
stateName
=
NameValue
.
stateName
.
extractBefore
(
2
)
...
+
"_{"
+
NameValue
.
stateName
.
extractAfter
(
1
)
+
"}(t)"
;
else
myOdeString
=
"\dot{"
+
NameValue
.
stateName
+
"}(t) &= "
;
NameValue
.
stateName
=
NameValue
.
stateName
+
"(t)"
;
end
myOdeString
=
myOdeString
+
misc
.
latexChar
(
obj
.
ss
{
1
}
.
A
)
+
NameValue
.
stateName
;
if
any
(
obj
.
ss
{
1
}
.
B
~=
0
)
if
misc
.
iseye
(
obj
.
ss
{
1
}
.
B
)
myOdeString
=
myOdeString
+
" + "
+
thisInputName
;
else
myOdeString
=
myOdeString
+
" + "
+
misc
.
latexChar
(
obj
.
ss
{
1
}
.
B
)
+
thisInputName
;
% get ODE-lines
myOdeString
=
myOdeString
+
misc
.
latexChar
(
obj
.
odes
.
A
)
+
NameValue
.
stateName
;
if
any
(
obj
.
odes
.
B
~=
0
)
if
~
misc
.
iseye
(
obj
.
odes
.
B
)
myOdeString
=
myOdeString
+
" + "
+
misc
.
latexChar
(
obj
.
odes
.
B
);
end
myOdeString
=
myOdeString
+
" + "
+
misc
.
latexChar
(
thisInputName
);
end
myOutputString
=
thisOutputName
+
"&= "
;
% get output-lines
myOutputString
=
misc
.
latexChar
(
thisOutputName
)
+
" &= "
;
plusNeeded
=
false
;
if
any
(
obj
.
ss
{
1
}
.
C
~=
0
)
if
misc
.
iseye
(
obj
.
ss
{
1
}
.
C
)
if
any
(
obj
.
odes
.
C
~=
0
)
if
misc
.
iseye
(
obj
.
odes
.
C
)
myOutputString
=
myOutputString
+
NameValue
.
stateName
;
else
myOutputString
=
myOutputString
+
...
misc
.
latexChar
(
obj
.
ss
{
1
}
.
C
)
+
NameValue
.
stateName
;
misc
.
latexChar
(
obj
.
odes
.
C
)
+
NameValue
.
stateName
;
end
plusNeeded
=
true
;
end
if
any
(
obj
.
ss
{
1
}
.
D
~=
0
)
if
any
(
obj
.
odes
.
D
~=
0
)
if
plusNeeded
myOutputString
=
myOutputString
+
" + "
;
end
if
misc
.
iseye
(
obj
.
ss
{
1
}
.
D
)
myOutputString
=
myOutputString
+
thisInputName
+
"(t)"
;
else
myOutputString
=
myOutputString
+
...
misc
.
latexChar
(
obj
.
ss
{
1
}
.
D
)
+
thisInputName
+
"(t)"
;
if
~
misc
.
iseye
(
obj
.
odes
.
D
)
myOutputString
=
myOutputString
+
misc
.
latexChar
(
obj
.
odes
.
D
);
end
myOutputString
=
myOutputString
+
misc
.
latexChar
(
thisInputName
);
end
myStringArray
=
[
myOdeString
;
myOutputString
];
...
...
@@ -356,14 +358,14 @@ classdef Odes < handle & matlab.mixin.Copyable
methods
(
Static
=
true
)
function
[
mySs
,
C
,
D
]
=
sep
e
rateOutputfromSs
(
mySs
,
type
)
function
[
mySs
,
C
,
D
]
=
sep
a
rateOutputfromSs
(
mySs
,
type
)
% separateCfromSs() removes the output matrix of a state space model mySs
% and replaces it with the identity matrix, in order to obtain the states
% of the ode as output variables. The old output matrix C results in a
% separate state space
if
all
(
strcmp
(
misc
.
ss
.
removeEnumeration
(
mySs
.
OutputName
),
type
))
assert
(
misc
.
iseye
(
mySs
.
C
)
&&
isequal
(
size
(
mySs
.
C
),
size
(
mySs
.
A
)),
...
[
'
output of states space model does not include all states
'
]
);
"
output of states space model does not include all states
"
);
C
=
ss
();
D
=
ss
();
else
...
...
@@ -380,9 +382,14 @@ classdef Odes < handle & matlab.mixin.Copyable
end
% change C and D in mySs
if
numel
(
mySs
.
A
)
==
1
mySsOutputName
=
type
;
else
mySsOutputName
=
type
+
"("
+
(
1
:
1
:
size
(
mySs
.
A
,
1
))
.'
+
")"
;
end
mySs
=
ss
(
mySs
.
A
,
mySs
.
B
,
eye
(
size
(
mySs
.
A
)),
zeros
(
size
(
mySs
.
A
,
1
),
size
(
mySs
.
B
,
2
)),
...
mySs
.
Ts
,
"InputName"
,
mySs
.
InputName
,
...
"OutputName"
,
type
+
"("
+
(
1
:
1
:
size
(
mySs
.
A
,
1
))
.'
+
")"
);
"OutputName"
,
mySsOutputName
);
end
% if
end
% function [ss, C] = seperateCfromSs(ss)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment