image thumbnail

MATLAB 5.x, SIMULINK 2.x: poradnik uzytkownika

by

 

22 Aug 2002 (Updated )

Companion Software

difmat1b.m
%-----------------------------------------------------------------
% Copyright 1998, by Bogumila and Zbigniew Mrozek, Krakow. For use
% with the book "MATLAB 5.x, SIMULINK 2.x, poradnik uzytkownika"
% (PLJ Warszawa, 1998,  ISBN 83-7101-376-0).
%-----------------------------------------------------------------
% see page 330, chapter 12.6.3 of the book,
% running simulation from MATLAB Command Window,
%                         model  'eqdif1b'
clear
options= simset('Solver','ode113','Refine',4);
[ts,ys]=sim('eqdif1b',[0 15],options);
ya= -2.*sin(ts) - cos(2.*ts);  %rozwiazanie analityczne
subplot(2,1,1)
plot(ts,ya,'r:',ts,ys(:,1),ts,ys(:,2),'m--')
legend('ya','y','dy/dt',-1)
title(['Rezultaty symulacji dla rwnania ',... 
       '  dy^{2}/dt^{2} - y = 4sin(t) + 5cos(2t)'])
subplot(2,1,2)
plot(ys(:,1),ys(:,2),xFinal(1),xFinal(2),'ro')
title('Wkres fazowy')
xlabel('y'); ylabel('dy/dt')

Contact us