Question: function updates = cowboyTryouts ( file , header ) % read file array = readcell ( file ) % get name column titles = array

function updates= cowboyTryouts (file, header)
%read file
array=readcell(file)
%get name column
titles = array(1,:)
info = array(2:end,:)
%delete favorite horse that are grey
color=strcmpi(titles,'Horse Color')
color1= info(:,color)
delete= strcmpi(color1, 'gray')
info(delete,:)=[]
% Create a new column called Stats
% which contains Lasso Time divided
% by Draw Time rounded to second decimal place
lasso=strcmpi(titles,'Lasso Time')
lasso1=info(:,lasso)
lasso= cell2mat(lasso1)
draw= strcmpi(titles, 'Draw Time')
draw1= info(:,draw)
draw= cell2mat(draw1)
Stats= lasso./draw
Stats= round(Stats,2)
titles =[titles 'Stats']
info =[info num2cell(Stats)]
%
% Sort the values based on
% the column with the header
% matching the second input string
% in descending order
base= strcmpi(titles,header)
col = info(:,base)
if ischar(col{1})
[header1, inds]= sort(col);
else
[newVar3,inds]= sort(cell2mat(col))
end
inds2=inds(end:-1:1)
%. Delete theinfo column with the header matching the second input string
info=info(inds2,:)
titles(:,base)=[]
info(:,base)=[]
updates=[titles;info]
end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!