function ds = runModel(ds)
% Copyright 2009 The MathWorks, Inc.
hw = waitbar(0,'Running Simulink Model...Please Wait');
nRuns = length(ds);
for run = 1:nRuns
model = updateModelParams(ds(run,:));
[t,x,y] = sim(model{:});
ds.unstable(run) = y(end,2);
ds.time(run) = {t};
ds.pitch(run) = {y(:,3)};
ds.plunge(run) = {y(:,4)};
ds.pitchFreq(run) = findPeak(t,ds.pitch{run});
ds.plungeFreq(run) = findPeak(t,ds.plunge{run});
s = sprintf('Running Iteration %s of %s',num2str(run),num2str(nRuns));
waitbar(run/nRuns,hw,s)
end
close(hw)
% Check UserData and Update
[r,c] = size(ds);
len = length(ds.Properties.UserData);
if len < c
ds.Properties.UserData(len+1:c) = repmat(nominal({'Response'}),1,c-len);
end