Question
MATLAB// Write a function PlaceStringsFirst to take any sized table as an input, identify all the columns that are strings and position these columns to
MATLAB// Write a function PlaceStringsFirst to take any sized table as an input, identify all the columns that are strings and position these columns to be the first columns in the table. The function should make use of CombineTwoTables and ExtractVariableNames already written. function table_out=PlaceStringsFirst(table_in) % Inputs: table_in: table of any size % Outputs: table_out: table with string columns positioned first columns in the table. end
% Clicker=PlaceStringsFirst(testTable) iClicker=PlaceStringsFirst_refcode(testTable)
+ ExtractVariableNames Function
function [columnVariablesNames, classTypes] =ExtractVariableNames(table_in) % Inputs: table_in: table of any size % Outputs: columnVariables: column variable names in a string row array % classTypes: associated data types in a string row array % % Insert code here
columns = table_in.Properties.VariableNames; columnVariablesNames=strings([1,length(columns)]); classTypes=strings([1,length(columns)]); for i = 1:length(columns) columnVariablesNames(i)=string(columns{i}); classTypes(i)=string(class(table_in.(columns{i}))); end end
+CombineTwoTables Function
function table_out=CombineTwoTables(table_in1,table_in2) % Inputs: table_in1: table of any size % table_in2: table of any size but with same number of rows as % table_in1 % Outputs: table_out: table that combines the two input tables % % Insert code here table_out = [table_in1 table_in2]; end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started