Code covered by the BSD License

# Using Analytical Tools to Gain Insight and Speed-up Num. Analysis in MATLAB & Symbolic Math Toolbox

### Deepak Ramaswamy (view profile)

28 Jan 2013 (Updated )

files from the webinar

bloodhoundPlotFcn(x,optimValues,state,varargin)
```%
% Copyright 2012 The MathWorks, Inc.
function stop = bloodhoundPlotFcn(x,optimValues,state,varargin)

mps2mph = 2.23694; % m/s to mph

stop = false;
switch state
case 'iter'
rs = x(1);
eo = x(2);
c1 = x(3);
c2 = x(4);

tb = velocity.tb(rs, eo, c1, c2);
ts = velocity.ts(rs, eo, c1, c2);

t1 = linspace(0,rs,20);
t2 = linspace(rs,eo,20);
t3 = linspace(eo,c1,20);
t4 = linspace(c1,c2,20);
t5 = linspace(c2,tb,20);
t6 = linspace(tb,ts,20);

v1 = mps2mph * velocity.vel1(t1, rs, eo, c1, c2);
v2 = mps2mph * velocity.vel2(t2, rs, eo, c1, c2);
v3 = mps2mph * velocity.vel3(t3, rs, eo, c1, c2);
v4 = mps2mph * velocity.vel4(t4, rs, eo, c1, c2);
v5 = mps2mph * velocity.vel5(t5, rs, eo, c1, c2);
v6 = mps2mph * velocity.vel6(t6, rs, eo, c1, c2);

if optimValues.iteration == 0
% The 'iter' case is  called during the zeroth iteration,
% but it now has values that were empty during the 'init' case
plot(t1,v1,'-b','Tag','plt1','LineWidth',2); hold on
plot(t2,v2,'-g','Tag','plt2','LineWidth',2);
plot(t3,v3,'-r','Tag','plt3','LineWidth',2);
plot(t4,v4,'-c','Tag','plt4','LineWidth',2);
plot(t5,v5,'-m','Tag','plt5','LineWidth',2);
plot(t6,v6,'-k','Tag','plt6','LineWidth',2);

title('Velocity Profile');
xlabel('Time (sec)'); ylabel('Velocity (mph)');
set(gca,'XLim',[0 90]);
set(gca,'YLim',[-100 1100]);
grid on

else
plt1 = findobj(get(gca,'Children'),'Tag','plt1');
plt2 = findobj(get(gca,'Children'),'Tag','plt2');
plt3 = findobj(get(gca,'Children'),'Tag','plt3');
plt4 = findobj(get(gca,'Children'),'Tag','plt4');
plt5 = findobj(get(gca,'Children'),'Tag','plt5');
plt6 = findobj(get(gca,'Children'),'Tag','plt6');

set(plt1,'XData',t1,'Ydata',v1);
set(plt2,'XData',t2,'Ydata',v2);
set(plt3,'XData',t3,'Ydata',v3);
set(plt4,'XData',t4,'Ydata',v4);
set(plt5,'XData',t5,'Ydata',v5);
set(plt6,'XData',t6,'Ydata',v6);
end
pause(1);
end```