Contents

Aaron Klapheck

% Ch 4. Assignment #10       due 11/14
clear, clc
Date = date
Date =

21-Nov-2007

Problem 28

% Find: t.
% Given: Amount (A) = 1000000, Principal (P) = 10000, and rate (r) = 6%.

% For each additional year the amount in the account is given by:
% A = (A + 10000) + (A + 10000)*r, which simplifies into:
% A = (A + 10000)*(1 + r)

P = 10000;, r = 0.06;
% initialize A and t.
A = 0;, t = 0;


while A < 1000000
    A = (A + 10000)*(1 + r);
    t = t + 1;
end % A < 1000000

number_of_years = t
number_of_years =

    33

Problem 31a

% Find: values of v_2 such that i_1, i_2, i_3, i_4, & i_5 <= .001.

% Given:

% eqn. #1: -v_1 + R_1*i_1 + R_4*i_4 = 0
% eqn. #2: -R_4*i_4 + R_2*i_2 + R_5*i_5 = 0
% eqn. #3:  -R_5*i_5 + R_3*i_3 + v_2 = 0
% eqn. #4:  i_1 = i_2 + i_4
% eqn. #5:  i_2 = i_3 + i_5

% Substitute equations #4 and #5 into #1, #2, and #3:

% #1:  (R_1 + R_4)*i_1 - R_4*i_2               + 0*i_3          = v_1
% #2:  -R_4*i_1        + (R_2 + R_4 + R_5)*i_2 - R_5*i_3        = 0
% #3:  0*i_1           + R_5*i_2               -(R_3 + R_5)*i_3 = v_2
% #4:  i_4 = i_1 - i_2
% #5:  i_5 = i_2 - i_3


% Given resister values:
R_1 = 5000; R_2 = 100000; R_3 = 200000; R_4 = 150000; R_5 = 250000;
v_1 = 100;


Matrix = [(R_1 + R_4), -R_4, 0; -R_4, (R_2 + R_4 + R_5), -R_5; ...
    0, R_5, -(R_3 + R_5)];

% innitiate current matrix and v_2.
current = [0; 0; 0; 0; 0];
v_2 = 100;
good_value_of_v_1 = 0;

while abs(current) <= 0.001*[1; 1; 1; 1; 1]
    b = [v_1; 0; v_2];
    i_1to3 = Matrix^(-1)*b;
    current=[i_1to3; i_1to3(1) - i_1to3(2); i_1to3(2) - i_1to3(3)];

    if abs(current)<=.001*[1;1;1;1;1]
        good_value_of_v_1 = v_2;
    end % abs(current)<=.001*[1;1;1;1;1]

    v_2 = v_2 - 0.01;
    if v_2 < 0
       break
    end %  v_2 < 0

end % abs(current) <= 0.001*[1; 1; 1; 1; 1]

v_2_ranges_from_0_to = good_value_of_v_1
b = [v_1; 0; v_2];
i_1to3 = Matrix^(-1)*b;
current_at_v_2 = [i_1to3; i_1to3(1) - i_1to3(2); i_1to3(2) - i_1to3(3)]
v_2_ranges_from_0_to =

   31.6700


current_at_v_2 =

    0.0010
    0.0004
    0.0001
    0.0006
    0.0002

Problem 33

% For Table:
% rows 1 through 3  represent the pass (there are only three passes!).
% columns 1 through 4 represent the variable being considered (k, b, x, and
% y respectively).

Table = [1, -2, -1, -2; 2, -2, 0, -2; 3, -3, 1, -3]


% Test answers in table

k = 1; b = -2; x = -1; y = -2;
while k<= 3
    k_b_x_y = [k, b, x, y]  %I made this a vecter because it is easier to see.
    y = x^2 - 3;
    if y < b
        b = y;
    end
    x = x + 1;
    k = k + 1;
end
Table =

     1    -2    -1    -2
     2    -2     0    -2
     3    -3     1    -3


k_b_x_y =

     1    -2    -1    -2


k_b_x_y =

     2    -2     0    -2


k_b_x_y =

     3    -3     1    -3

Problem 35

% This program computes the force nessasary to push an object along a
% surface given the objects weight (W) and the composition of the
% materials, (the object and the surface).

% User input:
W = input('Weight: ');
Material = input('choose material (metal on metal, wood on wood, metal on wood, rubber on concrete): ','s');

%
switch Material
    case 'metal on metal'
        mu = 0.20;
        Pushing_force = mu*W
    case 'wood on wood'
        mu = 0.35;
        Pushing_force = mu*W
    case 'metal on wood'
        mu = 0.40;
        Pushing_force = mu*W
    case 'rubber on concrete'
        mu = 0.70;
        Pushing_force = mu*W
    otherwise
        disp('Please choose only the four material combinations listed, order and spelling matter.')

end % Material
Error using ==> input
Cannot call INPUT from EVALC.

Problem 38

% This program computes the pressure exerted by a volume of gas.

% For volume_temperature(V,T)

% Imput variables:
% T = temperature in Kelvins (K).
% V = gas specific volume (L/mol).
% Gas = Helium (He), Hydrogen (H_2), Oxygen (O_2), Chlorine (Cl_2), Carbon
% dioxide (CO_2).

% Output variables:
% Pressure (atm).


volume_temperature(20,300);

The PDF version may be easier to understand, because it contains the problems that couldn't be evaluated.

Published with MATLAB® 7.0.1