Aaron Klapheck
clear, clc, home
fprintf('The date and time: %s \n \n', datestr(now))
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('% %')
disp('% Test 2. %')
disp('% Programer: Aaron Klapheck %')
disp('% %')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
fprintf('\n')
disp('%%%% Number 1. %%%%%')
A = [34, 55; 55, 89];
b = [21; 34];
[true] = solveMatrix(A, b);
fprintf('\nActule Value of x is %f \nActual value of y is %f \n', true)
fprintf('\npart a. \n \n')
[decimal17, Percent17] = relError([-.11; 0.45], true)
[decimal45, Percent45] = relError([-0.99; 1.01], true)
fprintf('\npart b. \n \n')
A = 'Test2.dat';
fprintf('Write to a file called %s \n \n',A)
indin = fopen(A, 'w');
if indin > 0
fprintf('File %s opened/created sucessfully \n \n', A)
else
fprintf('Warning! File %s not opened/created \n \n', A)
end
fprintf(indin,'The error of DoGood 17 is: %f percent for x and %f percent for y \n', Percent17);
fprintf(indin,'The error of MightDo 45 is: %f percent for x and %f percent for y \n', Percent45);
fprintf(indin,'I would recomend MightDo 45 because it has the lowest pecentage error. \n');
cl = fclose(indin);
if cl == 0
fprintf('File %s closed succesfully \n \n', A)
else
fprintf('Warning! File %s not closed \n \n', A)
end
disp('%%%% Number 2. %%%%%')
fprintf('\npart a. \n \n')
[Data, Text] = xlsread('MES08.xls');
Text
Data
fprintf('\npart b. \n \n')
t = Data(:,1);
h = Data(:,2);
t_new = [1:.1:5];
coefficients = FitToPoly(t, h)
fprintf('\npart c. \n \n')
A = 'Test2.dat';
fprintf('Write to a file called %s \n \n',A)
indin = fopen(A, 'a');
if indin > 0
fprintf('File %s opened/created sucessfully \n \n', A)
else
fprintf('Warning! File %s not opened/created \n \n', A)
end
fprintf(indin,'The constants evaluated for part (b) are: %f %f %f %f %f %f %f \n', coefficients);
cl = fclose(indin);
if cl == 0
fprintf('File %s closed succesfully \n \n', A)
else
fprintf('Warning! File %s not closed \n \n', A)
end
fprintf('Wrote the folowing to %s: \n', A)
type(A)
fprintf('\npart e. \n \n')
true = coefficients
measured = [0, 0, 0, 0, 0, -0.1064245, 0.498733]
[decimal, PercentA] = relError(measured, true)
true = coefficients
measured = [0, 0, 0, 1, 0, 0, 0]
[decimal, PercentA] = relError(measured, true)
A = 'Test2.dat';
fprintf('Write to a file called %s \n \n',A)
indin = fopen(A, 'a');
if indin > 0
fprintf('File %s opened/created sucessfully \n \n', A)
else
fprintf('Warning! File %s not opened/created \n \n', A)
end
fprintf(indin,'The error for A is: %f %f %f %f %f %f %f \n', PercentA);
fprintf(indin,'The error for B is: %f %f %f %f %f %f %f \n', PercentB);
cl = fclose(indin);
if cl == 0
fprintf('File %s closed succesfully \n \n', A)
else
fprintf('Warning! File %s not closed \n \n', A)
end
fprintf('\npart f. \n \n')
Undefined function or variable 'PercentB'.