Contents

Aaron Klapheck

% In class 25-Mar-08
clear, clc, home
fprintf('The date and time: %s \n', datestr(now))
The date and time: 08-Apr-2008 14:03:51 

Notes

%   Use Simulink to solve problem 12.3 on page 682
%       dy/dt = t - 2y
%       y(0) = 1
%
%               /-------- |2| <-------------\
%               |summing| --dy/dt--> |1/s| --y--> |scope|
%       |ramp|-/
%
%       see Simulink function problem12point3
%
%
%

1. Loading Simulink files (data files similar to .dat files)

clear, clc, home
fprintf('The date and time: %s \n \n', datestr(now))

disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%                                                                %')
disp('%                    Purpose: Loading Simulink files             %')
disp('%                    Programer: Aaron Klapheck                   %')
disp('%                                                                %')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')


fprintf('\nDirrectory is: \n')
dir     % check to see if P12point3.mat is present in current dirrectory

load P12point3.mat

fprintf('\nDisplay all variables: \n')
whos    % chech to see if yP12point3 is the variable.


% exact solution

t_exact = [0:.1:5];

y_exact = 1/4.*(2.*t_exact - 1 + 5.*exp(-2.*t_exact));

plot(yP12point3(1,:), yP12point3(2,:), 'o', t_exact, y_exact), ...
    legend('Simulink solution', 'Exact solution'),
The date and time: 08-Apr-2008 14:03:52 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                %
%                    Purpose: Loading Simulink files             %
%                    Programer: Aaron Klapheck                   %
%                                                                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Dirrectory is: 

.                    20-Mar-08.m          Interpolation.m      problem12point3.mdl  
..                   25-Mar-08.asv        P12point3.mat        rhs1.m               
11-Mar-08.m          25-Mar-08.m          SolveODE3rd.asv      
13-Mar-08.m          4-Mar-08.m           capacitor.dat        
18-Mar-08.m          6-Mar-08.m           html                 
20-Mar-08.asv        Gauss.m              linefit.m            


Display all variables: 
  Name             Size                    Bytes  Class

  yP12point3       2x52                      832  double array

Grand total is 104 elements using 832 bytes

Simulink Model: