% robustness_openloop.m - sSimulation of a NL system with varying dynamics
% KJA, 2012

aminit;					% initialize FBS macros

t = 0:0.01:6;
r = sin(t) + sin(pi*t) + sin(pi^2*t);
rr = -3:0.05:3;

% Open loop
for a = [0.1 0.2 0.5];
  for b = [0 0.5 1 2];
    y = fcn(r, a, b);
    yy = fcn(rr, a, b);

    figure(1)
    subplot(221);
    plot(rr, yy, 'r-', 'LineWidth', AM_thin_linewidth);
    hold on;

    figure(2)
    subplot(221);
    plot(t, y, 'r-', 'LineWidth', AM_thin_linewidth);
    hold on;
  end
 end

% Nominal nonlinearity
figure(1)
a = 0.2; b = 1;
xxx = -3:0.1:3;
ynom = fcn(xxx, a, b);
pl = plot(xxx, ynom, 'b--', xxx, xxx, 'b-');
set(pl, 'Linewidth', AM_thick_linewidth);

figure(2)
% a = 1; b = 1;
pl = plot(t, r, 'b-', t, fcn(r, a, b), 'b--');
set(pl, 'Linewidth', AM_thick_linewidth);

hold on;
figure(1)
line([-3 3], [0 0]);
line([0 0], [-20 20]);
amaxis([-3 3 -5 5]);
title('a');
xlabel('x'); ylabel('y');
amprint('rob-ol-io.eps')

figure(2)
amaxis([0 2 -1 5]);
xlabel('t'); ylabel('y');
title('b');
amprint('rob-ol-signals.eps')
