Answer:
Required MatLab code is given below:
Explanation:
function tableData=CreateTable(Names, Event, Weight)
% Matlab function to create a table from the given input arrays
% Inputs:
% Names will be n x 1 string array,
% Event will be n x 1 string array,
% Weight will be n x 1 double column array.
% Outputs:
% tableData : where column variables are : RowerNames, RowingEvent,
% RowerWeight and WeightCategories
WeightCategories = ""; % create an empty WeightCategories array
% loop over the Weight column array, populate the WeightCategories
% based on Weight
for i=1:length(Weight)
if(Weight(i) >= 100 && Weight(i) < 150)
WeightCategories(i) = "light weight";
elseif(Weight(i) >= 150 && Weight(i) < 200)
WeightCategories(i) = "medium weight";
else
WeightCategories(i) = "heavy weight";
end
end
% create the table with arrays Names, Events, Weight and
% WeightCategories by taking transpose of WeightCategories as WeightCategories is a row array
tableData = table(Names,Event,Weight,WeightCategories','VariableNames',{'RowerNames','RowingEvent','RowerWeight','WeightCategories'});
end
%end of function