From: <par...@us...> - 2010-10-09 13:08:16
|
Revision: 7827 http://octave.svn.sourceforge.net/octave/?rev=7827&view=rev Author: paramaniac Date: 2010-10-09 13:08:10 +0000 (Sat, 09 Oct 2010) Log Message: ----------- control: add sys_connect for frd models, improve constructor Modified Paths: -------------- trunk/octave-forge/main/control/devel/@frd/frd.m trunk/octave-forge/main/control/devel/__frd_dim__.m Added Paths: ----------- trunk/octave-forge/main/control/devel/@frd/__sys_connect__.m Added: trunk/octave-forge/main/control/devel/@frd/__sys_connect__.m =================================================================== --- trunk/octave-forge/main/control/devel/@frd/__sys_connect__.m (rev 0) +++ trunk/octave-forge/main/control/devel/@frd/__sys_connect__.m 2010-10-09 13:08:10 UTC (rev 7827) @@ -0,0 +1,54 @@ +## Copyright (C) 2010 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{retsys} =} __sys_connect__ (@var{sys}, @var{M}) +## This function is part of the Model Abstraction Layer. No argument checking. +## For internal use only. +## @example +## @group +## Problem: Solve the system equations of +## Y(s) = G(s) E(s) +## E(s) = U(s) + M Y(s) +## in order to build +## Y(s) = H(s) U(s) +## Solution: +## Y(s) = G(s) [U(s) + M Y(s)] +## Y(s) = G(s) U(s) + G(s) M Y(s) +## Y(s) = [I - G(s) M]^-1 G(s) U(s) +## \_______ _______/ +## H(s) +## @end group +## @end example +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: October 2010 +## Version: 0.1 + +function sys = __sys_connect__ (sys, M) + + [p, m, l] = size (sys.H); + + I = eye (p); + H = mat2cell (sys.H, p, m, ones (1, l))(:); + + H = cellfun (@(x) [I - x*M] \ x, H, "uniformoutput", false); + + sys.H = cat (3, H{:}); + +endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/devel/@frd/frd.m =================================================================== --- trunk/octave-forge/main/control/devel/@frd/frd.m 2010-10-09 11:32:29 UTC (rev 7826) +++ trunk/octave-forge/main/control/devel/@frd/frd.m 2010-10-09 13:08:10 UTC (rev 7827) @@ -73,8 +73,24 @@ endswitch + ## TODO: create separate function if (ndims (H) != 3 && ! isempty (H)) - H = reshape (H, 1, 1, []); + if (is_real_scalar (H)) # static gain (H is a scalar) + H = reshape (H, 1, 1, []); + tsam = -1; + elseif (isvector (H)) # SISO system (H is a vector) + H = reshape (H, 1, 1, []); + else # static gain (H is a matrix) + if (! is_real_matrix (H)) + error ("frd: static gain matrix must be real"); + endif + H = reshape (H, rows (H), []); + lw = length (w); + if (lw > 1) + H = repmat (H, [1, 1, lw]); # needed for "frd1 + matrix2" or "matrix1 * frd2) + endif + tsam = -1; + endif elseif (isempty (H)) H = zeros (0, 0, 0); tsam = -1; @@ -89,7 +105,7 @@ ltisys = lti (p, m, tsam); sys = class (frdata, "frd", ltisys); - +sys.lti.tsam if (argc > 0) sys = set (sys, varargin{:}); endif Modified: trunk/octave-forge/main/control/devel/__frd_dim__.m =================================================================== --- trunk/octave-forge/main/control/devel/__frd_dim__.m 2010-10-09 11:32:29 UTC (rev 7826) +++ trunk/octave-forge/main/control/devel/__frd_dim__.m 2010-10-09 13:08:10 UTC (rev 7827) @@ -29,6 +29,19 @@ error ("frd: H must be a 3-dimensional numeric array"); endif + lw = length (w); + + if (lw > 1 && (! is_real_vector (w) || any (w < 0) \ + || ! issorted (w) || w(1) >= w(end) || length (unique (w)) != lw)) + error ("frd: w must be a vector of positive real numbers"); + elseif (lw == 1 && ! issample (w, -1)) + error ("frd: scalar w must be a valid sampling time"); + endif +%{ + if (! isnumeric (H)) # TODO: watch out for __set__ vector case + error ("frd: H must be a 3-dimensional numeric array"); + endif + if (! isempty (w) && (! is_real_vector (w) || any (w < 0))) error ("frd: w must be a vector of positive real numbers"); endif @@ -37,8 +50,10 @@ if (lw > 1 && (! issorted (w) || w(1) >= w(end) || length (unique (w)) != lw)) error ("frd: vector w must contain unique frequencies in ascending order"); + elseif (lw == 1 && ! issample (w, -1)) + error ("frd: scalar w must be a valid sampling time"); endif - +%} [p, m, l] = size (H); if (l != lw) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |