From: <par...@us...> - 2012-02-23 15:44:20
|
Revision: 9672 http://octave.svn.sourceforge.net/octave/?rev=9672&view=rev Author: paramaniac Date: 2012-02-23 15:44:09 +0000 (Thu, 23 Feb 2012) Log Message: ----------- control-devel: handle sampling time Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/@iddata/iddata.m Added Paths: ----------- trunk/octave-forge/extra/control-devel/inst/__adjust_iddata_tsam__.m Modified: trunk/octave-forge/extra/control-devel/inst/@iddata/iddata.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/@iddata/iddata.m 2012-02-23 15:02:36 UTC (rev 9671) +++ trunk/octave-forge/extra/control-devel/inst/@iddata/iddata.m 2012-02-23 15:44:09 UTC (rev 9672) @@ -56,7 +56,7 @@ ## Created: October 2011 ## Version: 0.1 -function dat = iddata (y = [], u = [], tsam = -1, varargin) +function dat = iddata (y = [], u = [], tsam = [], varargin) if (nargin == 1 && isa (y, "iddata")) dat = y; @@ -65,13 +65,9 @@ print_usage (); endif - ## TODO: individual tsam for each experiment - if (! issample (tsam, -1)) - error ("iddata: invalid sampling time"); - endif - [y, u] = __adjust_iddata__ (y, u); [p, m, e] = __iddata_dim__ (y, u); + tsam = __adjust_iddata_tsam__ (tsam, e); outname = repmat ({""}, p, 1); inname = repmat ({""}, m, 1); @@ -79,7 +75,7 @@ dat = struct ("y", {y}, "outname", {outname}, "outunit", {outname}, "u", {u}, "inname", {inname}, "inunit", {inname}, - "tsam", tsam, "timeunit", {""}, + "tsam", {tsam}, "timeunit", {""}, "expname", {expname}, "name", "", "notes", {{}}, "userdata", []); Added: trunk/octave-forge/extra/control-devel/inst/__adjust_iddata_tsam__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__adjust_iddata_tsam__.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/__adjust_iddata_tsam__.m 2012-02-23 15:44:09 UTC (rev 9672) @@ -0,0 +1,48 @@ +## 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 -*- +## Check whether tsam is a e-by-1 cell array of valid sampling times. +## If not, it tries to convert tsam accordingly. +## Empty tsam are filled with default value 1. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: February 2012 +## Version: 0.1 + +function tsam = __adjust_iddata_tsam__ (tsam, e) + + if (isempty (tsam)) + tsam = num2cell (ones (e, 1)); + elseif (iscell (tsam)) + tsam = reshape (tsam, [], 1); + else + tsam = {tsam}; + endif + + tmp = cellfun (@issample, tsam); + + if (any (! tmp)) + error ("iddata: invalid sampling time"); + endif + + if (numel (tsam) != e) + error ("iddata: there are %d experiments, but only %d sampling times", \ + e, numel (tsam)); + endif + +endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |