Contents

Aaron Klapheck

% In class 13-Mar-08
clear, clc, home
fprintf('The date and time: %s \n', datestr(now))
The date and time: 18-Mar-2008 14:53:19 

Notes

% linear, similog, loglog
%   linear: line
%   semilog: exponential
%       Using x- and log(y)-axis then we would have a straight line.
%       See 1.
%       y = c1.*exp(c2.*x)
%       linefit
%           Note:       c1 = c(2) and c2 = c(1)!!!!!
%           input:      x, log(y)
%           output:     ln(c(2)), c(1)
%   loglog: polynomial
%       y = c1*x^(c2)
%       linefit
%           input:      log(x), log(y)
%           output:     ln(c(2)), c(1)
%
% Numerical Integration of ODE's - See Slide.
%   1 independant variable
%   order of DE is highest number of derivatives.
%
%   initial value problem (IVP)
%       Information given at initial point.
%   boundary value problem (BVP)
%       Informaion given at boundaries (initial point and final point).
%       Harder to solve, don't see much.
%       Break it up into a series of initial value problems.
%
%   Note for Boe-Bot:
%       For a Bot-Bot traveling the perameter of a square.
%       Use initial values at every instant to make Boe-Bot corrections.
%   Numerically
%       -ode23 use for "stiff", very exact, solutions. Don't use usually
%       because if a small mistake is made it is very difficult to correct.
%       -ode45 use for our class.
%           ode45(odefun, Tspan, Y0, Options, P1, P2,....)
%           Type "help ode45"
%           [T,Y] = ode45(...)
%               T = time
%               Y = y(n-1) derivatives, column vector.
%                   Ex: Y = [y; y'; y''; y'''; ....; y_n-2; y_n-2]
%           tolerance, leave as an empty matrix []
%           Tspan = time span
%           Y0 = innitial conditions
%
%
%

1. line fit exponential

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

disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%                                                                %')
disp('%                    Purpose: line fit an exponential            %')
disp('%                    Programer: Aaron Klapheck                   %')
disp('%                                                                %')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')


load capacitor.dat
t = capacitor(:,1);
v = capacitor(:,2);
ct = linefit(t, log(v));
c = [exp(ct(2)); ct(1)]
% v = 5e^(-10x)


y_new = c(1).*exp(c(2).*t)


plot(t,v,'o', t, y_new)
The date and time: 18-Mar-2008 14:53:19 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                %
%                    Purpose: line fit an exponential            %
%                    Programer: Aaron Klapheck                   %
%                                                                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

c =

    5.0000
  -10.0000


y_new =

    5.0000
    4.0936
    3.3516
    2.7441
    2.2466
    1.8394
    1.5060
    1.2330
    1.0095
    0.8265
    0.6767
    0.5540
    0.4536
    0.3714
    0.3041
    0.2489

1. line fit power

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

disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%                                                                %')
disp('%                    Purpose: line fit an power                  %')
disp('%                    Programer: Aaron Klapheck                   %')
disp('%                                                                %')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')


load capacitor.dat
y = [2.2361, 10.9329, 24.6765, 42.8382, 65.0486];
x = [1, 2.5, 4, 5.5, 7];
cx = linefit(log(x), log(y));
c = [exp(cx(2)); cx(1)]


y_new = c(1).*x.^c(2)


plot(x, y,'o', x, y_new)
The date and time: 18-Mar-2008 14:53:20 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                %
%                    Purpose: line fit an power                  %
%                    Programer: Aaron Klapheck                   %
%                                                                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

c =

    2.2361
    1.7320


y_new =

    2.2361   10.9330   24.6765   42.8381   65.0484