Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
conI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
LRT_infinite_dimensional_systems
conI
Commits
6e6785f9
Commit
6e6785f9
authored
5 years ago
by
Jakob Gabriel
Browse files
Options
Downloads
Patches
Plain Diff
misc.ss.discreteDifferentiationSs: implement differentiation as discrete state space
parent
f3e5540a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
+misc/+ss/discreteDifferentiationSs.m
+52
-0
52 additions, 0 deletions
+misc/+ss/discreteDifferentiationSs.m
with
52 additions
and
0 deletions
+misc/+ss/discreteDifferentiationSs.m
0 → 100644
+
52
−
0
View file @
6e6785f9
function
myStateSpace
=
discreteDifferentiationSs
(
numberSignal
,
inputName
,
...
stepSize
,
varargin
)
% misc.ss.discreteDifferentiationSs implements numerical differentiation for run time
% use in simulations by implementing the differentiation
% y_t = (y(t) - y(t-)) / stepSize
% via a time-discrete state-space (see >> doc ss ).
%
% Inputs:
% numberSignal number of differentiation signals
% inputName name of signal to be differentiated
% stepSize spacing between time steps of simulation
% Optional Input:
% outputName name of differentiated signal
%
% Outputs:
% myStateSpace the state space that differentiates input of signalName
%
% Example:
% -------------------------------------------------------------------------
% exampleSs = ss(0.8, 1, 1, [], 1e-3, 'OutputName', 'y', 'InputName', 'u');
% diffSs = misc.ss.discreteDifferentiationSs(1, 'y', 1e-3, ...
% 'outputName', 'dydt');
% simSs = misc.ss.connect({'u'}, {'y', 'dydt'}, exampleSs, diffSs);
% [simOutput, t, ~] = initial(simSs, [1; 1], 0:1e-3:50*1e-3);
% simData = misc.ss.simulationOutput2Quantity(simOutput, t, simSs.OutputName);
% plot([simData.y.diff(1, 't'); simData.dydt])
% -------------------------------------------------------------------------
% input reading
myParser
=
misc
.
Parser
();
myParser
.
addParameter
(
'outputName'
,
[
inputName
,
'_t'
],
@
(
v
)
ischar
(
v
));
myParser
.
parse
(
varargin
{:});
% input checks
assert
(
isnumeric
(
numberSignal
));
assert
(
isnumeric
(
stepSize
)
&&
isscalar
(
stepSize
));
assert
(
ischar
(
inputName
),
'inputName must be a character-array or string'
);
% create time discrete signal model that represents the time derivative described
% above
myStateSpace
=
ss
(
...
zeros
(
numberSignal
),
...
% A
eye
(
numberSignal
),
...
% B
-
eye
(
numberSignal
)/
stepSize
,
...
% C
eye
(
numberSignal
)/
stepSize
,
...
% D
stepSize
);
% Ts
% set signal names
myStateSpace
=
misc
.
ss
.
setSignalName
(
myStateSpace
,
'input'
,
{
inputName
},
{
numberSignal
});
myStateSpace
=
misc
.
ss
.
setSignalName
(
myStateSpace
,
'output'
,
...
{
myParser
.
Results
.
outputName
},
{
numberSignal
});
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment