From: <par...@us...> - 2010-09-13 09:19:48
|
Revision: 7705 http://octave.svn.sourceforge.net/octave/?rev=7705&view=rev Author: paramaniac Date: 2010-09-13 09:19:41 +0000 (Mon, 13 Sep 2010) Log Message: ----------- control: use reshape Modified Paths: -------------- trunk/octave-forge/main/control/inst/@lti/set.m trunk/octave-forge/main/control/inst/@ss/__set__.m trunk/octave-forge/main/control/inst/@tfpoly/tfpoly.m trunk/octave-forge/main/control/inst/__checkname__.m trunk/octave-forge/main/control/inst/__freqbounds__.m trunk/octave-forge/main/control/inst/__getfreqresp__.m trunk/octave-forge/main/control/inst/__tf2ss__.m trunk/octave-forge/main/control/inst/__timeresp__.m trunk/octave-forge/main/control/inst/bode.m trunk/octave-forge/main/control/inst/bodemag.m trunk/octave-forge/main/control/inst/gensig.m trunk/octave-forge/main/control/inst/lsim.m trunk/octave-forge/main/control/inst/margin.m trunk/octave-forge/main/control/inst/nichols.m trunk/octave-forge/main/control/inst/nyquist.m trunk/octave-forge/main/control/inst/place.m trunk/octave-forge/main/control/inst/rlocus.m trunk/octave-forge/main/control/inst/sigma.m Modified: trunk/octave-forge/main/control/inst/@lti/set.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/set.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/@lti/set.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009 - 2010 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -23,7 +23,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.1 +## Version: 0.2 function retsys = set (sys, varargin) @@ -60,10 +60,10 @@ switch (prop) case {"inname", "inputname"} - sys.inname = __checkname__ (val, m)(:); + sys.inname = __checkname__ (val, m); case {"outname", "outputname"} - sys.outname = __checkname__ (val, p)(:); + sys.outname = __checkname__ (val, p); case {"tsam", "ts"} if (issample (val)) Modified: trunk/octave-forge/main/control/inst/@ss/__set__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__set__.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/@ss/__set__.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -43,7 +43,7 @@ case {"stname", "statename"} n = rows (sys.a); - sys.stname = __checkname__ (val, n)(:); + sys.stname = __checkname__ (val, n); otherwise error ("set: invalid property name"); Modified: trunk/octave-forge/main/control/inst/@tfpoly/tfpoly.m =================================================================== --- trunk/octave-forge/main/control/inst/@tfpoly/tfpoly.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/@tfpoly/tfpoly.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009 - 2010 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -20,7 +20,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2009 -## Version: 0.1 +## Version: 0.2 function p = tfpoly (a) @@ -35,8 +35,8 @@ if (isa (a, "tfpoly")) p = a; return; - elseif (isvector (a) && isreal (a)) - p.poly = a(:).'; + elseif (isreal (a) && isvector (a)) + p.poly = reshape (a, 1, []); p = class (p, "tfpoly"); p = __remleadzer__ (p); else Modified: trunk/octave-forge/main/control/inst/__checkname__.m =================================================================== --- trunk/octave-forge/main/control/inst/__checkname__.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/__checkname__.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009 -2010 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -21,7 +21,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.1 +## Version: 0.2 function name = __checkname__ (name, req_len) @@ -29,9 +29,9 @@ name = {name}; # e.g. sys = set (sys, "inname", "u_1") endif - n = numel (name); + name = reshape (name, [], 1); - if (n != req_len) + if (numel (name) != req_len) error ("lti: set: cell must contain %d strings", req_len); endif Modified: trunk/octave-forge/main/control/inst/__freqbounds__.m =================================================================== --- trunk/octave-forge/main/control/inst/__freqbounds__.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/__freqbounds__.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -45,8 +45,8 @@ discrete = (tsam > 0); # static gains (tsam = -1) are continuous ## make sure zer, pol are row vectors - pol = pol(:).'; - zer = zer(:).'; + pol = reshape (pol, 1, []); + zer = reshape (zer, 1, []); ## check for natural frequencies away from omega = 0 if (discrete) Modified: trunk/octave-forge/main/control/inst/__getfreqresp__.m =================================================================== --- trunk/octave-forge/main/control/inst/__getfreqresp__.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/__getfreqresp__.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -30,7 +30,7 @@ error ("getfreqresp: first argument sys must be a LTI system"); endif - if (! isvector (w) && ! isempty (w)) + if (! isempty (w) && ! (isreal (w) && isvector (w))) error ("getfreqresp: second argument w must be a vector of frequencies"); endif Modified: trunk/octave-forge/main/control/inst/__tf2ss__.m =================================================================== --- trunk/octave-forge/main/control/inst/__tf2ss__.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/__tf2ss__.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -87,8 +87,8 @@ endif ## force num, den to be row vectors - num = vec (num).'; - den = vec (den).'; + num = reshape (num, 1, []); + den = reshape (den, 1, []); nn = length (num); nd = length (den); if (nn > nd) Modified: trunk/octave-forge/main/control/inst/__timeresp__.m =================================================================== --- trunk/octave-forge/main/control/inst/__timeresp__.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/__timeresp__.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009 - 2010 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -20,7 +20,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.1 +## Version: 0.2 function [y, t, x_arr] = __timeresp__ (sys, resptype, plotflag, tfinal, dt, x0) @@ -58,7 +58,7 @@ p = rows (C); # number of outputs ## time vector - t = (0 : dt : tfinal).'; + t = reshape (0 : dt : tfinal, [], 1); l_t = length (t); switch (resptype) @@ -71,7 +71,7 @@ x_arr = zeros (l_t, n); ## initial conditions - x = x0(:); # make sure that x is a column vector + x = reshape (x0, [], 1); # make sure that x is a column vector if (n != length (x0)) error ("initial: x0 must be a vector with %d elements", n); Modified: trunk/octave-forge/main/control/inst/bode.m =================================================================== --- trunk/octave-forge/main/control/inst/bode.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/bode.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009 - 2010 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -45,7 +45,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.1 +## Version: 0.2 function [mag_r, pha_r, w_r] = bode (sys, w = []) @@ -55,7 +55,7 @@ [H, w] = __getfreqresp__ (sys, w, false, 0, "std"); - H = H(:); + H = reshape (H, [], 1); mag = abs (H); pha = unwrap (arg (H)) * 180 / pi; @@ -63,9 +63,9 @@ mag_db = 20 * log10 (mag); wv = [min(w), max(w)]; - ax_vec_mag = __axis2dlim__ ([w(:), mag_db(:)]); + ax_vec_mag = __axis2dlim__ ([reshape(w, [], 1), reshape(mag_db, [], 1)]); ax_vec_mag(1:2) = wv; - ax_vec_pha = __axis2dlim__ ([w(:), pha(:)]); + ax_vec_pha = __axis2dlim__ ([reshape(w, [], 1), reshape(pha, [], 1)]); ax_vec_pha(1:2) = wv; if (isct (sys)) Modified: trunk/octave-forge/main/control/inst/bodemag.m =================================================================== --- trunk/octave-forge/main/control/inst/bodemag.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/bodemag.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009 - 2010 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -43,7 +43,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.1 +## Version: 0.2 function [mag_r, w_r] = bodemag (sys, w = []) @@ -53,14 +53,14 @@ [H, w] = __getfreqresp__ (sys, w, false, 0, "std"); - H = H(:); + H = reshape (H, [], 1); mag = abs (H); if (! nargout) mag_db = 20 * log10 (mag); wv = [min(w), max(w)]; - ax_vec_mag = __axis2dlim__ ([w(:), mag_db(:)]); + ax_vec_mag = __axis2dlim__ ([reshape(w, [], 1), reshape(mag_db, [], 1)]); ax_vec_mag(1:2) = wv; if (isct (sys)) Modified: trunk/octave-forge/main/control/inst/gensig.m =================================================================== --- trunk/octave-forge/main/control/inst/gensig.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/gensig.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -52,7 +52,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: August 2009 -## Version: 0.2 +## Version: 0.2.1 function [u, t] = gensig (sigtype, tau, tfinal, tsam) @@ -80,7 +80,7 @@ error ("gensig: fourth argument is not a valid sampling time"); endif - t = (0 : tsam : tfinal).'; + t = reshape (0 : tsam : tfinal, [], 1); switch (lower (sigtype(1:2))) case "si" Modified: trunk/octave-forge/main/control/inst/lsim.m =================================================================== --- trunk/octave-forge/main/control/inst/lsim.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/lsim.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009 - 2010 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -51,7 +51,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.1 +## Version: 0.2 function [y_r, t_r, x_r] = lsim (sys, u, t = [], x0 = [], method = "zoh") @@ -101,7 +101,7 @@ m = columns (G); # number of inputs p = rows (C); # number of outputs - t = (0 : dt : tfinal).'; # time vector + t = reshape (0 : dt : tfinal, [], 1); # time vector trows = length (t); if (urows != trows) @@ -123,7 +123,7 @@ error ("initial: x0 must be a vector with %d elements", n); endif - x = x0(:); # make sure that x is a column vector + x = reshape (x0, [], 1); # make sure that x is a column vector ## simulation for k = 1 : trows Modified: trunk/octave-forge/main/control/inst/margin.m =================================================================== --- trunk/octave-forge/main/control/inst/margin.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/margin.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009 - 2010 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -119,7 +119,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: July 2009 -## Version: 0.7.0 +## Version: 0.7.1 function [gamma_r, phi_r, w_gamma_r, w_phi_r] = margin (sys, tol = sqrt (eps)) @@ -262,15 +262,15 @@ [H, w] = __getfreqresp__ (sys, [], false, 0, "std"); - H = H(:); + H = reshape (H, [], 1); mag_db = 20 * log10 (abs (H)); pha = unwrap (arg (H)) * 180 / pi; gamma_db = 20 * log10 (gamma); wv = [min(w), max(w)]; - ax_vec_mag = __axis2dlim__ ([w(:), mag_db(:)]); + ax_vec_mag = __axis2dlim__ ([reshape(w, [], 1), reshape(mag_db, [], 1)]); ax_vec_mag(1:2) = wv; - ax_vec_pha = __axis2dlim__ ([w(:), pha(:)]); + ax_vec_pha = __axis2dlim__ ([reshape(w, [], 1), reshape(pha, [], 1)]); ax_vec_pha(1:2) = wv; wgm = [w_gamma, w_gamma]; Modified: trunk/octave-forge/main/control/inst/nichols.m =================================================================== --- trunk/octave-forge/main/control/inst/nichols.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/nichols.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009 - 2010 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -45,7 +45,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.1 +## Version: 0.2 function [mag_r, pha_r, w_r] = nichols (sys, w = []) @@ -55,13 +55,13 @@ [H, w] = __getfreqresp__ (sys, w, false, 0, "ext"); - H = H(:); + H = reshape (H, [], 1); mag = abs (H); pha = unwrap (arg (H)) * 180 / pi; if (! nargout) mag_db = 20 * log10 (mag); - ax_vec = __axis2dlim__ ([pha(:), mag_db(:)]); + ax_vec = __axis2dlim__ ([reshape(pha, [], 1), reshape(mag_db, [], 1)]); plot (pha, mag_db) axis (ax_vec) Modified: trunk/octave-forge/main/control/inst/nyquist.m =================================================================== --- trunk/octave-forge/main/control/inst/nyquist.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/nyquist.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009 - 2010 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -45,7 +45,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.1 +## Version: 0.2 function [re_r, im_r, w_r] = nyquist (sys, w = []) @@ -55,7 +55,7 @@ [H, w] = __getfreqresp__ (sys, w, false, 0, "ext"); - H = H(:); + H = reshape (H, [], 1); re = real (H); im = imag (H); Modified: trunk/octave-forge/main/control/inst/place.m =================================================================== --- trunk/octave-forge/main/control/inst/place.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/place.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -67,7 +67,7 @@ ## Special thanks to Peter Benner from TU Chemnitz for his advice. ## Author: Lukas Reichlin <luk...@gm...> ## Created: December 2009 -## Version: 0.2.2 +## Version: 0.2.3 function [f, nfp, nap, nup] = place (a, b, p = [], alpha = [], tol = []) @@ -101,7 +101,7 @@ error ("place: p must be a vector"); endif - p = sort (p(:)); # complex conjugate pairs must appear together + p = sort (reshape (p, [], 1)); # complex conjugate pairs must appear together wr = real (p); wi = imag (p); Modified: trunk/octave-forge/main/control/inst/rlocus.m =================================================================== --- trunk/octave-forge/main/control/inst/rlocus.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/rlocus.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -21,37 +21,35 @@ ## @deftypefnx {Function File} {[@var{rldata}, @var{k}] =} rlocus (@var{sys}[, @var{increment}, @var{min_k}, @var{max_k}]) ## Display root locus plot of the specified @acronym{SISO} system. ## -## @example -## @group -## u + +---+ +------+ y -## ------>(+)----->| k |----->| SISO |-------+-------> -## ^ - +---+ +------+ | -## | | -## +---------------------------------+ -## @end group -## @end example -## ## @strong{Inputs} ## @table @var ## @item sys -## LTI model +## LTI model. Must be a single-input and single-output (SISO) system. ## @item min_k -## Minimum value of @var{k} +## Minimum value of @var{k}. ## @item max_k -## Maximum value of @var{k} +## Maximum value of @var{k}. ## @item increment -## The increment used in computing gain values +## The increment used in computing gain values. ## @end table ## ## @strong{Outputs} -## -## Plots the root locus to the screen. ## @table @var ## @item rldata ## Data points plotted: in column 1 real values, in column 2 the imaginary values. ## @item k ## Gains for real axis break points. ## @end table +## +## @example +## @group +## u + +---+ +------+ y +## ------>(+)----->| k |----->| SISO |-------+-------> +## ^ - +---+ +------+ | +## | | +## +---------------------------------+ +## @end group +## @end example ## @end deftypefn ## Author: David Clem @@ -61,7 +59,7 @@ ## Adapted-By: Lukas Reichlin <luk...@gm...> ## Date: December 2009 -## Version: 0.1 +## Version: 0.2 ## TODO: Improve compatibility @@ -150,7 +148,7 @@ ngain = max (30, ngain); gvec = linspace (mink, maxk, ngain); if (length (k_break)) - gvec = sort ([gvec, vec(k_break).']); + gvec = sort ([gvec, reshape(k_break, 1, [])]); endif ## Find the open loop zeros and the initial poles @@ -296,20 +294,21 @@ title ("Root Locus"); xlabel (sprintf ("Real Axis gain = [%g, %g]", gvec(1), gvec(ngain))); ylabel ("Imaginary Axis"); - set (gcf (), "visible","on"); + set (gcf (), "visible", "on"); else rldata_r = rldata; endif endfunction -function rlpol = sort_roots (rlpol,tolx, toly) +function rlpol = sort_roots (rlpol, tolx, toly) # no point sorting of you've only got one pole! if (rows (rlpol) == 1) return; endif # reorder entries in each column of rlpol to be by their nearest-neighbors +rlpol dp = diff (rlpol.').'; drp = max (real (dp)); dip = max (imag (dp)); Modified: trunk/octave-forge/main/control/inst/sigma.m =================================================================== --- trunk/octave-forge/main/control/inst/sigma.m 2010-09-12 23:03:20 UTC (rev 7704) +++ trunk/octave-forge/main/control/inst/sigma.m 2010-09-13 09:19:41 UTC (rev 7705) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009 - 2010 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -57,7 +57,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: May 2009 -## Version: 0.3.0 +## Version: 0.3.1 function [sv_r, w_r] = sigma (sys, w = [], resptype = 0) @@ -82,7 +82,8 @@ sv_db = 20 * log10 (sv); ## determine axes - ax_vec = __axis2dlim__ ([w(:), min(sv_db, [], 1)(:); w(:), max(sv_db, [], 1)(:)]); + ax_vec = __axis2dlim__ ([reshape(w, [], 1), reshape(min(sv_db, [], 1), [], 1); + reshape(w, [], 1), reshape(max(sv_db, [], 1), [], 1)]); ax_vec(1:2) = [min(w), max(w)]; ## determine xlabel @@ -101,7 +102,7 @@ grid ("on") else # return values sv_r = sv; - w_r = w(:); + w_r = reshape (w, [], 1); endif endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |