No BSD License  

Highlights from
OCTool

from OCTool by Tim Farajian
This is a graphical interface for optimizing the time-delayed open/closed-loop control ...

plotresponse(sys, modal)
function hFig = plotresponse(sys, modal)

if nargin<2 || isempty(modal)
    modal = true;
end

sys.To = linspace(0,sys.To,100); % 100 discrete values over time
[t W dW Z dZ] = response(sys); % Calculate response

hFig = figure;
if modal
    plot(t,Z) % Plot modal repsonse
    ax = axis;
    axis([t(1) t(end) ax(3:4)])
    legend('Mode 1','Mode 2','Mode 3')
    title('Modal responses  z(t)')
else
    osys=sys; 
    osys.cp=0;osys.cd=0;
    osys.a=0*osys.a;osys.b=0*osys.b;
    osys.To = linspace(0,4*t(end));
    [tu Wu] = response(osys);
    osys.xo = Z(end,:);osys.vo = dZ(end,:);
    osys.To = linspace(0,3*t(end));        
    [ta Wa] = response(osys);
    
    plot(tu,Wu,'k') % Plot total repsonse
    hold on
    plot(t,W,'r')
    plot(ta+t(end),Wa,'b')
    legend('No Control','During Control','After Control')
    plot([0 4*t(end)],[0 0],'k--') 
    ax = axis;
    plot([t(end) t(end)],ax(3:4),'k--')
    axis([0 4*t(end) ax(3:4)])
    hold off
    title('Total displacement  W(x,t)')
end
xlabel('Time (s)')
ylabel('Displacement (m)');

Contact us at files@mathworks.com