Mercurial > forge
changeset 9558:a648e1df94cb octave-forge
control-devel: catenation types for iddata class
author | paramaniac |
---|---|
date | Sun, 04 Mar 2012 22:17:45 +0000 |
parents | 71f71a885bcd |
children | 22154252a545 |
files | extra/control-devel/devel/iddata_merge.m extra/control-devel/inst/@iddata/cat.m extra/control-devel/inst/@iddata/diff.m |
diffstat | 3 files changed, 58 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extra/control-devel/devel/iddata_merge.m Sun Mar 04 22:17:45 2012 +0000 @@ -0,0 +1,14 @@ +%u = iddata ({(1:10).', (21:30).'}, {(41:50).', (61:70).'}); +%v = iddata ({(11:20).', (31:40).'}, {(51:60).', (71:80).'}); + +oy = ones (200, 5); +ou = ones (200, 4); +y = repmat ({oy}, 6, 1); +u = repmat ({ou}, 6, 1); + +u = iddata (y, u) +v = u + +a = [u, v] +b = [u; v] +c = merge (u, v) \ No newline at end of file
--- a/extra/control-devel/inst/@iddata/cat.m Sun Mar 04 17:35:42 2012 +0000 +++ b/extra/control-devel/inst/@iddata/cat.m Sun Mar 04 22:17:45 2012 +0000 @@ -26,39 +26,25 @@ function dat = cat (dim, varargin) + tmp = cellfun (@iddata, varargin); + switch (dim) - case 1 # add samples; p, m, e identical - %[~, p, m, e] - %nvec = cellfun (@size - %[~, p, m, e] = cellfun (@size, varargin, "uniformoutput", false) - - %y = cellfun (@(dat) vertcat (dat.y) - %dat = cellfun (@iddata, varargin) - #y = cellfun (@vertcat - - #ycell = cellfun (@(dat) dat.y, varargin, "uniformoutput", false) - - tmp = cellfun (@iddata, varargin); + case 1 # vertcat - catenate samples y = cellfun (@vertcat, tmp.y, "uniformoutput", false); u = cellfun (@vertcat, tmp.u, "uniformoutput", false); - - dat = iddata (y, u); - - %varargin{:}.y - %varargin(:).y - case 2 # horzcat, same outputs; - case 3 # vertcat, same inputs + case 2 # horzcat - catenate channels; + y = cellfun (@horzcat, tmp.y, "uniformoutput", false); + u = cellfun (@horzcat, tmp.u, "uniformoutput", false); - case 4 # add experiments - tmp = cellfun (@iddata, varargin); - + case 3 # merge - catenate experiments y = vertcat (tmp.y); u = vertcat (tmp.u); - - dat = iddata (y, u); - + + otherwise + error ("iddata: cat: '%s' is an invalid dimension", num2str (dim)); + endswitch - endswitch + dat = iddata (y, u); endfunction \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extra/control-devel/inst/@iddata/diff.m Sun Mar 04 22:17:45 2012 +0000 @@ -0,0 +1,32 @@ +## Copyright (C) 2012 Lukas F. Reichlin +## +## This file is part of LTI Syncope. +## +## LTI Syncope is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## LTI Syncope is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{dat} =} cat (@var{dim}, @var{dat1}, @var{dat2}, @dots{}) +## Concatenation of iddata objects along dimension @var{dim}. +## @end deftypefn + +## Author: Lukas Reichlin <lukas.reichlin@gmail.com> +## Created: March 2012 +## Version: 0.1 + +function dat = diff (dat, k) + + dat.y = cellfun (@(y) diff (y, k), dat.y, "uniformoutput", false); + dat.u = cellfun (@(u) diff (u, k), dat.u, "uniformoutput", false); + +endfunction \ No newline at end of file