Contents

Aaron Klapheck

% Ch 3. Assignment #7       due 10/24
clear, clc
Date = date
Date =

22-Oct-2007

Problem 14

% Given: V(t) = 10^9 + 10^8*(1 - exp(-t/100)) - r*t.
% Where V is the volume of water in L, t is the time in days, and r is
% the town's consumption rate of water in L/day.



Percentage_of_Water_Loss(50,10^7);
Warning: The value of local variables may have been changed to match the
         globals.  Future versions of MATLAB will require that you declare
         a variable to be global before you use that variable.
Warning: The value of local variables may have been changed to match the
         globals.  Future versions of MATLAB will require that you declare
         a variable to be global before you use that variable.

Days_Needed =

   54.1832

Problem 16a (compute V & A for a between 0.25 & 4 and b = a + 2)

% Given: A volume function and an area function for a torus.
% V(a,b) = (1/4*pi^2).*(a+b).*(b-a).^2,
% A(a,b) = pi^2.*(b.^2-a.^2)
% where V = volume, A = area, a = inner radius, and b = outer radius.


a = linspace(0.25, 4, 20);

b = a + 2;

[Area_of_Torus, Volume_of_Torus] = V_and_A(a,b)
Area_of_Torus =

  Columns 1 through 9 

   49.3480   57.1398   64.9316   72.7234   80.5152   88.3070   96.0988  103.8906  111.6824

  Columns 10 through 18 

  119.4742  127.2660  135.0577  142.8495  150.6413  158.4331  166.2249  174.0167  181.8085

  Columns 19 through 20 

  189.6003  197.3921


Volume_of_Torus =

  Columns 1 through 9 

   24.6740   28.5699   32.4658   36.3617   40.2576   44.1535   48.0494   51.9453   55.8412

  Columns 10 through 18 

   59.7371   63.6330   67.5289   71.4248   75.3207   79.2166   83.1125   87.0084   90.9043

  Columns 19 through 20 

   94.8001   98.6960

Problem 20b

poly = @(x) (20*x.^2 - 200.*x + 3)

% General location of minimum
interval = [-50:1:50];
plot(interval, poly(interval));         % a.

% The mimimum is around x = 8.

[position, value] = fminbnd(poly,0,8)   % b.
poly = 

    @(x) (20*x.^2 - 200.*x + 3)


position =

    5.0000


value =

  -497

Problem 23

% The function Minimum_of_f1 computes the minumum of of the function
% f1, where f1 = 20*x^2-200*x +3.



f1 = Minimum_of_f1(20, 200, 3);

[x_value, y_value] = fminbnd(f1, 0, 10)
x_value =

    5.0000


y_value =

  -497

Problem 24

% Load a

load matrix.txt

matrix

Mean_Value_of_Each_Column = mean(matrix, 1)
matrix =

    55    42    98
    51    39    95
    63    43    94
    58    45    90


Mean_Value_of_Each_Column =

   56.7500   42.2500   94.2500

Problem 25

A = xlsread('matrix_1')

Sum_of_Each_Column = sum(A)
A =

    55    42    98
    51    39    95
    63    43    94
    58    45    90


Sum_of_Each_Column =

   227   169   377

The PDF version may be easier to understand, because it contains all the functions called in this program.