Contents

Aaron Klapheck

% Ch 6 & 7. Assignment #14       due 12/10
clear, clc
date
ans =

17-Dec-2007

Chapter 6

Problem 6

% Purpose
% The goal of this excersize is to find X (and verify the answer).

% Given
% A*X = b, where A is a matrix and X & b are column vecters.

% a.

A = [2, 1; 3, -9]; b = [5; 2];
X = A\b

% check
should_be_b = A*X
% should_be_b = b, therefore X = [x; y].


% b.

A = [-8, -5; -2, 7]; b = [4; 10];
X = A\b

% check
should_be_b = A*X
% should_be_b = b, therefore X = [x; y].
X =

    2.2381
    0.5238


should_be_b =

     5
     2


X =

   -1.1818
    1.0909


should_be_b =

    4.0000
   10.0000

Problem 8

% Purpose
% The goal of this excersize is to find X.

% Given
% A*X = b, where A is a matrix and X & b are column vecters.

% a.

A = [-2, 1; -2, 1]; b = [-5; -5.00001]; % the two lines are nearly identical.
X = A\b

% MATLAB says that the two lines intersect at infinity (positive or
% negative it does not matter). Only parallel lines intersect at infinity.
% One way to check this using MATLAB is to take the determinate. If the
% determinate is zero then the two lines are parallel.

determinate = det(A)


% b.

A = [1, 5, -1, 6; 2, -1, 1, -2; -1, 4, -1, 3; 3, -7, -2, 1];
b = [19; 7; 20; -75];
X = A\b

% check
X_1 = A^(-1)*b
% X_1 = X, therefore X = [x1; x2; x3; x4].
Warning: Matrix is singular to working precision.

X =

  -Inf
  -Inf


determinate =

     0


X =

    2.0000
   10.0000
    3.0000
   -5.0000


X_1 =

    2.0000
   10.0000
    3.0000
   -5.0000

Problem 9

% Purpose
% The goal of this excersize is to set up a script file that solves for
% the six currents given the five resistances and voltage v.
% Then use this script file to solve a particulare problem.

% Given
% 3 voltage equations and 3 current equations (1 current equation is
% redundent).

% 0*i_1   - R_2*i_2 + 0*i_3   - R_4*i_4 + 0*i_5   + 0*i_6 = -v
% R_1*i_1 - R_2*i_2 + R_3*i_3 + 0*i_4   + 0*i_5   + 0*i_6 = 0
% 0*i_1   + 0*i_2   - R_3*i_3 - R_4*i_4 + R_5*i_5 + 0*i_6 = 0
% 1*i_1   + 1*i_2   + 0*i_3   + 0*i_4   + 0*i_5   - 1*i_6 = 0
% 0*i_1   + 1*i_2   + 1*i_3   - 1*i_4   + 0*i_5   + 0*i_6 = 0
% -1*i_1  + 0*i_2   + 1*i_3   + 0*i_4   + 1*i_5   + 0*i_6 = 0

% Set values of R_1, R_2, R_3, R_4, R_5, and v below
R_1 = 1000; R_2 = 5000; R_3 = 2000; R_4 = 10000; R_5 = 5000; v = 100;


A = [0 , -R_2, 0   , -R_4, 0  , 0 ; ...
    R_1, -R_2, R_3 , 0   , 0  , 0 ; ...
    0  , 0   , -R_3, -R_4, R_5, 0 ; ...
    1  , 1   , 0   , 0   , 0  , -1; ...
    0  , 1   , 1   , -1  , 0  , 0 ; ...
    -1 , 0   , 1   , 0   , 1  , 0  ];

b = [-v; 0; 0; 0; 0; 0];

i_1_through_i_6_in_Amps = A\b
i_1_through_i_6_in_Amps =

    0.0189
    0.0049
    0.0027
    0.0076
    0.0162
    0.0238

Chapter 7

Problem 1 - Absolute frequency histogram

% Purpose
% The goal of this excersize is to take the list Mileage and plot its
% absolute frequency histogram and relative frequency histogram.

% Given

Mileage = sort([23, 25, 26, 25, 27, 25, 24, 22, 23, 25, 26, 26, 24, ...
    24, 22, 25, 26, 24, 24, 24, 27, 23]);
x = [22:27];

Mileage_length = length(Mileage);

hist(Mileage, x), ylabel('Absolute Frequency'), ...
    xlabel('Mileage (miles per gallon)'), grid, ...
    title('Absolute Frequency Histogram for 22 Milaeges')

Problem 1 - Relative frequency histogram

y = [2, 3, 6, 5, 4, 2]./Mileage_length;
x = [22:27];
bar(x, y), ylabel('Relative Frequency'), ...
    xlabel('Mileage (miles per gallon)'), grid, ...
    title('Relative Frequency Histogram for 22 Mileages')

Problem 2 - Bin width of 50

% Purpose
% The goal of this excersize is to take the list Breaking_force and plot
% its absolute frequency histogram using bin widths of 50, 100, and 200 lb.
% After doing the above, identification of the most meaningfull bin width
% is stated.
% Lastly, a band width was found that was even more meaningful than the
% three listed above.

% Given

Breaking_force = sort([243, 236, 389, 628, 143, 417, 205, ...
    404, 464, 605, 137, 123, 372, 439, ...
    497, 500, 535, 577, 441, 231, 675, ...
    132, 196, 217, 660, 569, 865, 725, ...
    457, 347]);

bin_width_50 = [100:50:900];

hist(Breaking_force, bin_width_50), ylabel('Absolute Frequency'), ...
    xlabel('Breaking Force (lb)'), grid, ...
    title('Absolute Frequency Histogram for 30 Breaking Forces for Bin Widths of 50')

Problem 2 - Bin width of 100

bin_width_100 = [100:100:900];
hist(Breaking_force, bin_width_100), ylabel('Absolute Frequency'), ...
    xlabel('Breaking Force (lb)'), grid, ...
    title('Absolute Frequency Histogram for 30 Breaking Forces for Bin Widths of 100')

Problem 2 - Bin width of 200

bin_width_200 = [100:200:900];
hist(Breaking_force, bin_width_200), ylabel('Absolute Frequency'), ...
    xlabel('Breaking Force (lb)'), grid, ...
    title('Absolute Frequency Histogram for 30 Breaking Forces for Bin Widths of 200')

% Of the three bin widths the bin width of 200 gives the most meaningfull
% histogram.

Problem 2 - Better bin width

% A better bin width would be 150lb

better_bin_width = [100:150:900];
hist(Breaking_force, better_bin_width), ylabel('Absolute Frequency'), ...
    xlabel('Breaking Force (lb)'), grid, ...
    title('Absolute Frequency Histogram for 30 Breaking Forces for Bin Widths of 250')

Problem 5

% Purpose
% The goal of this excersize is to use the list Mileage (see problem # 1)
% to plot the scaled frequency histogram (part a.).
% For part b. the mean and standard deviation was calculated and used to
% estimate the lower and upper limits of gas mileage corresponding to 68%
% of cars of this model.
% 68% of the data will lie within 1 standard deviation of the mean value.
% Finally, the limits found above were compared with those of the data.

% Given

% Absolute frequency data.
Mileage_abs = [2, 3, 6, 5, 4, 2];
binwidth = 1;

% Computation of scaled frequency data.
area = binwidth*sum(Mileage_abs);
Mileage_scaled = Mileage_abs/area;

bins = [22:binwidth:27];

% Plot Scaled Frequency Histogram.
bar(bins, Mileage_scaled), ylabel('Scaled Frequency'), ...
    xlabel('Mileage (miles per gallon)'), grid, ...
    title('Scaled Frequency Histogram for 22 Mileages')

% Compute the mean and the standard deviation.
Mean = mean(Mileage)
Standard_deviation = std(Mileage)
% Upper and lower limits.
Upper_bound = Mean + Standard_deviation % approximately 26
Lower_bound = Mean - Standard_deviation % approximately 23

% Compair with data.
% 18 out of 22 car mileages lie within the range 23 to 26 therefore our
% upper bound and lower bound are accurate.
Mean =

   24.5455


Standard_deviation =

    1.4385


Upper_bound =

   25.9839


Lower_bound =

   23.1070