image thumbnail

Accurate Modeling in Simulink

by

 

03 Nov 2006 (Updated )

These files accompany the November 2006 article in MATLAB Digest

solver_profiling.m
%% Solver Profiling

%% Set the solver to save solver profile info

set_param(bdroot,'SolverProfileInfoName','stat')
set_param(bdroot,'SaveSolverProfileInfo','yes')

%% Display Time step size

h2 = findobj(0, 'Name', 'ABS Time Steps');
if isempty(h2),
  h2=figure(... %'Position',[26   239   452   257],...
           'Name','ABS Time Steps',...
           'NumberTitle','off');
end

figure(h2)

plot(tout(2:end),diff(tout))
title(['Model Step Size' 10 get_param(bdroot,'Solver') ' took ' num2str(length(tout)-1) ' steps'])
ylabel('Step Size(secs)')
xlabel('Time(secs)')
set(get(gca,'xlabel'),'FontSize',10);
set(get(gca,'ylabel'),'FontSize',10);
set(get(gca,'title'),'FontSize',10);

%%
set(gca,'YScale','log')
grid on

Contact us