Contents

Aaron Klapheck

% Lab day 28-Feb-08
clear, clc, home
fprintf('The date and time: %s \n', datestr(now))
The date and time: 18-Mar-2008 15:56:35 

Tasks 2

% Solve 8.29
%
%   a) create a function file that reads R, V and sends it to a function
%   b) create a datafile(s) that stores
%       R vector and V vector
%       (i) use .dat format
%       (ii) use .xls format
%   c) call the function that accepts, R and V and returns i
%   d) Print data
%
%   e) do Problem 8.10 (d, f, h). Use for loop, rank, fprintf.
%       note: for consistancy: rank(A) = rand([A B])
%             uniqueness: rank(A) = n = # of unknows

Solve 8.29

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

disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%                                               %')
disp('%         Purpose: Solve 8.29                   %')
disp('%         Programer: Aaron Klapheck             %')
disp('%                                               %')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')

% (R_1 + R_2)*i_1 - R_2*i_2 + 0*i_3 + 0*i_4 = -v_1 + v_3
% -R_2*i_1 + (R_2 + R_3 + R_4 + R_5)*i_2 + 0*i_3 - R_5*i_4 = -v_2
% 0*i_1 + 0*i_2 + (R_6 + R_8 + R_7)*i_3 - R_8*i_4 = -v_3 - v_4
% 0*i_1 - R_5*i_2 - R_8*i_3 + (R_8 + R_5 + R_9)*i_4 = v_4 - v_5


% Tested both lines of code below and they work correctly.
% Re = xlsread('Resistance.xls')'
% Vol = xlsread('voltage.xls')'



fprintf('\nRead a file called Resistance.dat \n \n')
fileID1 = fopen('Resistance.dat', 'r');
    Re = fscanf(fileID1, '%g', [1,9]); % note resistance in kilohms.
fclose(fileID1);

fprintf('Read a file called voltage.dat \n \n')
fileID2 = fopen('voltage.dat', 'r');
    Vol = fscanf(fileID2, '%g', [1,5]);
fclose(fileID2);



[i] = Current(Vol, Re);

A = [[1;2;3;4] i];

fprintf('\t current \n')
fprintf('number    value(miliamps) \n')
fprintf('------------------------- \n')
fprintf('%4.0f \t %10.4f \n', A')
fprintf('\n')
The date and time: 18-Mar-2008 15:56:35 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                               %
%         Purpose: Solve 8.29                   %
%         Programer: Aaron Klapheck             %
%                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Read a file called Resistance.dat 
 
Read a file called voltage.dat 
 
	 current 
number    value(miliamps) 
------------------------- 
   1 	    -1.3546 
   2 	    -1.0274 
   3 	    -1.2632 
   4 	    -0.7896 

Solve 8.10 (d, f, h)

disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%                                               %')
disp('%         Purpose: Solve 8.10 (d, f, h)         %')
disp('%         Programer: Aaron Klapheck             %')
disp('%                                               %')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')

% (d)
D = [1, 0; 0, 0];
d = [0; 0];

% (f)
F = [1, 1; 1, 0; 0, 1];
f = [1; -1; -1];

% (h)
H = [1, 2, -3, 1; 0, 1, -2, 1; 1, 0, 1, -1];
h = [-1; 2; 1];

% Aaron's own consistent and unique system
J = [1, 4; 3, 9];
j = [3; 8];


fprintf('\nSolution for 8.10(d) \n')
solveMatrix(D,d);
fprintf('\nSolution for 8.10(f) \n')
solveMatrix(F,f);
fprintf('\nSolution for 8.10(h) \n')
solveMatrix(H,h);
fprintf('\nSolution for 8.10 Aarons system 1 \n')
solveMatrix(J,j);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                               %
%         Purpose: Solve 8.10 (d, f, h)         %
%         Programer: Aaron Klapheck             %
%                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Solution for 8.10(d) 
Rank of A is:  1 
Rank of [A b] is:  1 
Number of unknows:  2 
system is consistent. 
system is not unique therefore there is no solution. 

Solution for 8.10(f) 
Rank of A is:  2 
Rank of [A b] is:  3 
Number of unknows:  2 
system is not consistent. 
system is unique. 
system has no solutions because 
there are more independant equations than unknows. 

Solution for 8.10(h) 
Rank of A is:  2 
Rank of [A b] is:  3 
Number of unknows:  4 
system is not consistent. 
system is not unique therefore there is no solution. 

Solution for 8.10 Aarons system 1 
Rank of A is:  2 
Rank of [A b] is:  2 
Number of unknows:  2 
system is consistent. 
system is unique. 
Solution is: 1.666667 
Solution is: 0.333333