From: <par...@us...> - 2012-09-18 05:58:41
|
Revision: 11045 http://octave.svn.sourceforge.net/octave/?rev=11045&view=rev Author: paramaniac Date: 2012-09-18 05:58:35 +0000 (Tue, 18 Sep 2012) Log Message: ----------- control: print legend with system names Modified Paths: -------------- trunk/octave-forge/main/control/devel/__time_response_2__.m trunk/octave-forge/main/control/devel/step2.m Modified: trunk/octave-forge/main/control/devel/__time_response_2__.m =================================================================== --- trunk/octave-forge/main/control/devel/__time_response_2__.m 2012-09-18 05:41:47 UTC (rev 11044) +++ trunk/octave-forge/main/control/devel/__time_response_2__.m 2012-09-18 05:58:35 UTC (rev 11045) @@ -23,7 +23,7 @@ ## Version: 0.3 % function [y, t, x_arr] = __time_response_2__ (sys, resptype, plotflag, tfinal, dt, x0, sysname) -function [y, t, x] = __time_response_2__ (resptype, args, plotflag) +function [y, t, x] = __time_response_2__ (resptype, args, sysname, plotflag) sys_idx = cellfun (@isa, args, {"lti"}); # look for LTI models sys_cell = cellfun (@ss, args(sys_idx), "uniformoutput", false); # convert to state-space @@ -188,6 +188,9 @@ endif endfor xlabel ("Time [s]"); + if (p == 1 && m == 1) + legend (sysname) + endif hold off; endif Modified: trunk/octave-forge/main/control/devel/step2.m =================================================================== --- trunk/octave-forge/main/control/devel/step2.m 2012-09-18 05:41:47 UTC (rev 11044) +++ trunk/octave-forge/main/control/devel/step2.m 2012-09-18 05:58:35 UTC (rev 11045) @@ -62,14 +62,23 @@ if (nargin == 0) print_usage (); endif - - %tmp = cellfun (@isa, varargin, {"lti"}); - %sys_idx = find (tmp); - - %sys_names = arrayfun (@inputname, sys_idx); + if (nargout) + sysname = {}; + else + sys_idx = find (cellfun (@isa, varargin, {"lti"})); + len = length (sys_idx); + sysname = cell (len, 1); + for k = 1 : len + try + sysname{k} = inputname(sys_idx(k)); + catch + sysname{k} = ""; + end_try_catch + endfor + endif - [y, t, x] = __time_response_2__ ("step", varargin, ! nargout); + [y, t, x] = __time_response_2__ ("step", varargin, sysname, ! nargout); if (nargout) y_r = y{1}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |