% Lab #9 on 10-Apr-08 clear, clc, home fprintf('The date and time: %s \n', datestr(now))
The date and time: 10-Apr-2008 16:02:55
View past Boe-Bot projects at gaia.ecs.csus.edu/~eke or go to CSUS ecs page and go to facalty then Eke
Also go to Web CT to download the Boe-Bot book. Click weblinks then click Robotics with the Boe-Bot.
clear, clc, home disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') disp('% %') disp('% Purpose: Solve 1st order ODE Using Simulink Embedded Function %') disp('% %') disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') % Solve: dy/dt = at + bty; y(0) = 1, where a = b = 1. fprintf('\nDirrectory is: \n') dir load SimDEfirstEmbed.mat fprintf('\nDisplay all variables: \n') whos % Anilytical function. t = [0:.1:20]; a = 1; b = 1; y = -1/b.*(a - (a + b).*exp((b.*t.^2)./2)); % Plot both plot(yDEfirstEmbed(1,:), yDEfirstEmbed(2,:),t, log(y)), legend('Numerical Simulink', 'Exact')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Purpose: Solve 1st order ODE Using Simulink Embedded Function % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Dirrectory is: . SimSolveDE1stEmbeddedFunction_sfun.dll .. SimSolveDE3rdEmbeddedFunction.mdl Lab9.asv SimSolveDE3rdEmbeddedFunction_sfun.dll Lab9.m SimSolveDE5thEmbeddedFunction.mdl SimDEfifth.mat SimSolveDE5thEmbeddedFunction_sfun.dll SimDEfifthEmbed.mat html SimDEfirstEmbed.mat sfprj SimDEthirdEmbed.mat SimSolveDE1stEmbeddedFunction.mdl Display all variables: Name Size Bytes Class yDEfirstEmbed 2x175 2800 double array Grand total is 350 elements using 2800 bytes
Simulink Model:
clear, clc, home fprintf('The date and time: %s \n \n', datestr(now)) disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') disp('% %') disp('% Purpose: solve 3rd order ODE IVP %') disp('% %') disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') fprintf('\nSolution obtained from: http://answers.yahoo.com/question/index?qid=20080324172753AAhCKCQ') % Solve a*y''' + b*y' = 0, y''(0) = 1, y'(0) = 0, y(0) = 1 % y''' = -b/a*y' fprintf('\nDirrectory is: \n') dir load SimDEthirdEmbed.mat fprintf('\nDisplay all variables: \n') whos % Analitic solution t = [0:0.1:10]; y = [2 - cos(t)]; % Plot both plot(yDEthirdEmbed(1,:), yDEthirdEmbed(2,:), t, y), legend('Numerical Simulink', 'Exact')
The date and time: 10-Apr-2008 16:03:00 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Purpose: solve 3rd order ODE IVP % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Solution obtained from: http://answers.yahoo.com/question/index?qid=20080324172753AAhCKCQ Dirrectory is: . SimSolveDE1stEmbeddedFunction_sfun.dll .. SimSolveDE3rdEmbeddedFunction.mdl Lab9.asv SimSolveDE3rdEmbeddedFunction_sfun.dll Lab9.m SimSolveDE5thEmbeddedFunction.mdl SimDEfifth.mat SimSolveDE5thEmbeddedFunction_sfun.dll SimDEfifthEmbed.mat html SimDEfirstEmbed.mat sfprj SimDEthirdEmbed.mat SimSolveDE1stEmbeddedFunction.mdl Display all variables: Name Size Bytes Class yDEthirdEmbed 2x56 896 double array Grand total is 112 elements using 896 bytes
Simulink Model:
clear, clc, home fprintf('The date and time: %s \n \n', datestr(now)) disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') disp('% %') disp('% Purpose: solve 5th order ODE IVP %') disp('% %') disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') fprintf('\nSolution obtained from: http://ltcconline.net/greenl/courses/204/appsHigherOrder/HigherConstants.htm') % Solve: a*y''''' - b*y''' = 0 % With IV: y(0) = 2, y'(0) = 3, y''(0) = 1, y'''(0) = -1, y''''(0) = 1 % y''''' = b/a*y''' fprintf('\nDirrectory is: \n') dir load SimDEfifthEmbed.mat fprintf('\nDisplay all variables: \n') whos % Analitic solution t = [0:0.1:10]; y = 31/16 + (23/4).*t + (5/8).*t.^2 + (1/16).*cos(2.*t) + (1/8).*sin(2.*t); % Plot both plot(yDEfifthEmbed(1,:), yDEfifthEmbed(2,:), t, y), legend('Numerical Simulink', 'Exact')
The date and time: 10-Apr-2008 16:03:01 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Purpose: solve 5th order ODE IVP % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Solution obtained from: http://ltcconline.net/greenl/courses/204/appsHigherOrder/HigherConstants.htm Dirrectory is: . SimSolveDE1stEmbeddedFunction_sfun.dll .. SimSolveDE3rdEmbeddedFunction.mdl Lab9.asv SimSolveDE3rdEmbeddedFunction_sfun.dll Lab9.m SimSolveDE5thEmbeddedFunction.mdl SimDEfifth.mat SimSolveDE5thEmbeddedFunction_sfun.dll SimDEfifthEmbed.mat html SimDEfirstEmbed.mat sfprj SimDEthirdEmbed.mat SimSolveDE1stEmbeddedFunction.mdl Display all variables: Name Size Bytes Class yDEfifthEmbed 2x52 832 double array Grand total is 104 elements using 832 bytes
Simulink Model: