You are on page 1of 3

11/7/15 3:39 PM

MATLAB Command Window

1 of 3

>> % Script File: Information for a biomaedical experiment


%
% Created: 11/6/15
% Author: Amber Adkins
%
% Description:
% Create a program that should read in the data from the text file in
% CANVAS description called homework_9.txt, and sort the participants
% into alphabetical order based upon last name.
%
% Variables:
% a = opening text file
% alph = sorting names
% pop_out = pop out menu
% weight_min = weight min
% weight_max = weight max
% weight_avg = weight average
% p = positive amount of RH Factors
% n = negitive amount of RH Factors
% Create a switch case
a = fopen('Homework_9.txt'); % opens text file
[first,last,weight,b_t,rh_f] = textread('Homework_9.txt','%s%s%s%s%s');
% Sorts names by last name alphabetically
% disp('Participants Sorted by Last Names');
b(:,1) = first;
b(:,2) = last;
b(:,3) = weight;
b(:,4) = b_t;
b(:,5) = rh_f;
Participants = sortrows(b,2)
% Pop cut menu for user to select one of the choices to be presented in command window
pop_out = 1;
while pop_out ~= 4
pop_out = menu('Please Select One','Weights','Blood Types','RH Factor', 'Quit');
if pop_out == 1
% Weight --> Max, Min, Avg weights
weight= cell2mat(weight);
weight = str2num(weight);
weight_min = min(weight)
weight_max = max(weight)
weight_avg= mean(weight)
elseif pop_out == 2
% Blood Types --> Pie-chart of blood types
blood_graph = categorical(b_t);

11/7/15 3:39 PM

MATLAB Command Window

pie(blood_graph);
elseif pop_out == 3
% RH Factor --> Horizontal bar graph among participants
rhf = [rh_f{:,:}];
p = strfind(rhf,'postitive');
x = length(p);
n = strfind(rhf,'negative');
y = length(n);
bargraph = [x,y];
figure
barh(bargraph);
ylabel ('(+) and (-) RH Factors');
xlabel('How many (+) and (-) RH Factors');
x = 0:0.1:10;
legend('1 = Positive, 2 = Negative');
else pop_out == 4
% End program
disp('Have a Nice Day');

end
end
fclose('all');
Participants =
'Milton'
'Suzette'
'Ginny'
'Mervin'
'Maira'
'Denise'
'Steve'
'Cayla'
'Corie'
'Reda'
'Christy'
'Evita'
'Rolande'
'Tinisha'
'Colton'
'Contessa'
'Lynette'
'Adrianna'
'Toby'
'Launa'
weight_min =
108

'Anderson'
'Bartlet'
'Beam'
'Brown'
'Davis'
'Doe'
'Garcia'
'Hernandez'
'Jackson'
'Johnson'
'Jones'
'Martin'
'Martinez'
'Miller'
'Moore'
'Rodriguez'
'Taylor'
'Thomas'
'Williams'
'Wilson'

'141'
'152'
'108'
'145'
'158'
'159'
'223'
'174'
'142'
'253'
'165'
'131'
'191'
'134'
'257'
'187'
'114'
'127'
'178'
'156'

'a'
'a'
'ab'
'b'
'a'
'o'
'b'
'b'
'ab'
'o'
'ab'
'b'
'o'
'b'
'a'
'ab'
'b'
'ab'
'a'
'o'

'negative'
'postitive'
'postitive'
'postitive'
'negative'
'negative'
'postitive'
'negative'
'postitive'
'postitive'
'negative'
'negative'
'postitive'
'postitive'
'postitive'
'postitive'
'postitive'
'negative'
'negative'
'negative'

2 of 3

11/7/15 3:39 PM

weight_max =
257
weight_avg =
164.7500
ans =
1
Have a Nice Day
>>

MATLAB Command Window

3 of 3

You might also like