Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students explore these related Databases questions

Question

To find integral of sin(logx) .

Answered: 3 weeks ago

Question

What are Decision Trees?

Answered: 3 weeks ago

Question

What is meant by the Term Glass Ceiling?

Answered: 3 weeks ago