From: <par...@us...> - 2012-09-17 20:17:24
|
Revision: 11041 http://octave.svn.sourceforge.net/octave/?rev=11041&view=rev Author: paramaniac Date: 2012-09-17 20:17:18 +0000 (Mon, 17 Sep 2012) Log Message: ----------- control: tighten axes Modified Paths: -------------- trunk/octave-forge/main/control/devel/__time_response_2__.m trunk/octave-forge/main/control/devel/multiplot2.m trunk/octave-forge/main/control/devel/multiplot3.m Modified: trunk/octave-forge/main/control/devel/__time_response_2__.m =================================================================== --- trunk/octave-forge/main/control/devel/__time_response_2__.m 2012-09-17 15:09:54 UTC (rev 11040) +++ trunk/octave-forge/main/control/devel/__time_response_2__.m 2012-09-17 20:17:18 UTC (rev 11041) @@ -34,8 +34,8 @@ tmp = cellfun (@is_real_matrix, args); vec_idx = find (tmp); - n_vec = length (vec_idx) - n_sys = length (sys_cell) + n_vec = length (vec_idx); + n_sys = length (sys_cell); %if (n_vec >= 1) % arg = args{vec_idx(1)}; @@ -47,14 +47,14 @@ tfinal = []; dt = {[]}; - [tfinal, dt] = cellfun (@__sim_horizon__, sys_cell, {tfinal}, dt, "uniformoutput", false); + %[tfinal, dt] = cellfun (@__sim_horizon__, sys_cell, {tfinal}, dt, "uniformoutput", false); + + [tfinal, dt] = cellfun (@__sim_horizon__, sys_cell, {tfinal}, "uniformoutput", false); tfinal = max ([tfinal{:}]); - % __sim_horizon__ (sys, tfinal, dt); - - - %hier sim_horizon +dt + ct_idx = cellfun (@isct, sys_cell); sys_dt_cell = sys_cell; @@ -143,34 +143,42 @@ for i = 1 : n_sys discrete = ! ct_idx(i); - if (discrete) # discrete system + if (discrete) # discrete-time system for k = 1 : p for j = 1 : cols subplot (p, cols, (k-1)*cols+j); stairs (t{i}, y{i}(:, k, j)); hold on; - grid ("on"); - if (i == n_sys && k == 1 && j == 1) - title (str); + grid on; + if (i == n_sys) + axis tight; + ylim (__axis_margin__ (ylim)) + if (j == 1) + ylabel (outname{k}); + if (k == 1) + title (str); + endif + endif endif - if (i == n_sys && j == 1) - ylabel (outname{k}); - endif endfor endfor - else # continuous system + else # continuous-time system for k = 1 : p for j = 1 : cols subplot (p, cols, (k-1)*cols+j); plot (t{i}, y{i}(:, k, j)); hold on; - grid ("on"); - if (i == n_sys && k == 1 && j == 1) - title (str); + grid on; + if (i == n_sys) + axis tight + ylim (__axis_margin__ (ylim)) + if (j == 1) + ylabel (outname{k}); + if (k == 1) + title (str); + endif + endif endif - if (i == n_sys && j == 1) - ylabel (outname{k}); - endif endfor endfor endif @@ -305,8 +313,10 @@ T_DEF = 10; # default simulation time ev = pole (sys); - n = length (ev); - discrete = ! isct (sys); + n = length (ev); # number of states/poles + continuous = isct (sys); + discrete = ! continuous; + Ts = get (sys, "tsam"); if (discrete) ## perform bilinear transformation on poles in z @@ -334,14 +344,14 @@ tfinal = T_DEF; endif - if (! discrete) + if (continuous) dt = tfinal / N_DEF; endif else ev = ev(find (ev)); ev_max = max (abs (ev)); - if (! discrete) + if (continuous) dt = 0.2 * pi / ev_max; endif @@ -354,7 +364,7 @@ tfinal = yy * ceil (tfinal / yy); endif - if (! discrete) + if (continuous) N = tfinal / dt; if (N < N_MIN) @@ -367,8 +377,8 @@ endif endif - if (! isempty (Ts)) # catch case cont. system with dt specified - dt = Ts; - endif + %if (! isempty (Ts)) # catch case cont. system with dt specified + % dt = Ts; + %endif endfunction Modified: trunk/octave-forge/main/control/devel/multiplot2.m =================================================================== --- trunk/octave-forge/main/control/devel/multiplot2.m 2012-09-17 15:09:54 UTC (rev 11040) +++ trunk/octave-forge/main/control/devel/multiplot2.m 2012-09-17 20:17:18 UTC (rev 11041) @@ -72,7 +72,6 @@ Kr4 = spaconred (P, K, 4, 'feedback', '-') Kr2 = spaconred (P, K, 2, 'feedback', '-') -%{ % Open Loop L = P * K; Lr4 = P * Kr4; @@ -82,7 +81,6 @@ T = feedback (L); Tr4 = feedback (Lr4); Tr2 = feedback (Lr2); -%} % Frequency Range w = {1e-2, 1e1}; @@ -94,6 +92,10 @@ % title ('Bode Diagrams of K and Kr') legend ('K (8 states)', 'Kr (4 states)', 'Kr (2 states)', 'location', 'southwest') +% Step Response of Closed Loop +figure (2) +step2 (T, Tr4, Tr2) + %{ % Step Response of Closed Loop [y, t] = step (T, 100); Modified: trunk/octave-forge/main/control/devel/multiplot3.m =================================================================== --- trunk/octave-forge/main/control/devel/multiplot3.m 2012-09-17 15:09:54 UTC (rev 11040) +++ trunk/octave-forge/main/control/devel/multiplot3.m 2012-09-17 20:17:18 UTC (rev 11041) @@ -2,3 +2,7 @@ figure (1) step2 (T_AH, T_opt) + + +figure (2) +step2 (T_AH, c2d (T_opt, 1)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |