Answered step by step
Verified Expert Solution
Question
1 Approved Answer
use matlab: Manipulating Tabular Data With Numeric and String Arrays Many important problems require processing both numeric data and text / string data. Consider the
use matlab: Manipulating Tabular Data With Numeric and String Arrays
Many important problems require processing both numeric data and textstring data. Consider the following table showing the number of silicon wafers processed by three semiconductor manufacturers over four consecutive quarters:
Q Q Q Q
Intel
TSMC
Global Foundries
To manipulate this heterogeneous data in MATLAB, one can use the table data class or one can construct two homogeneous arrays:
foundryList "Intel"; TSMC; "Global Foundries"; D string column array
foundryList times string
"Intel"
TSMC
"Global Foundries"
numWafers ;
;
; D numeric array
numWafers times
Note that the D string column array has the same number of rows as the D numeric array.
Logical indexing can be used to identify specific subsets of the data. The same specific subsets can also be found by using nested loops to process all the numeric data and keeping track of which row the data is found in For example, one can imagine writing some nested loops that would return the largest number of wafers processed, all the quarterly wafer numbers greater than the foundry with the fewest wafers processed in any given quarter, and the foundry with the most wafers processed in any given quarter. The code that computes these results can be encapsulated in a custom function. For the data above, below is an example of what your custom function would return if the arguments have the correct type and dimensions:
maxNumWafers, largeNumWafers, foundryMinWafers, foundryMaxWafers, errResult, errString MyProblemFunctionnumWafersfoundryList
maxNumWafers
largeNumWafers times
foundryMinWafers "Global Foundries"
foundryMaxWafers TSMC
errResult logical
errString
In this miniproject, you will define your own tabular data problem that uses a D numeric array and a D string column array to represent the data, and you will solve that problem with a custom function using the template below. The D numeric array and D string column array are inputs to your function. Your custom function must:
Return seven results: a numeric scalar result based on the data in the D numeric array, a numeric array result based on the data in the D numeric array, and two string scalar results from the input D string column array based on the data in the D numeric array, a logical scalar error result error flag a scalar error string result, and a table constructed from the input D string column array as the first table column and the D numeric array as the remaining table columns.
Perform the following input data checks: check that the input arguments are the correct type, check that the input numeric array is D check that the input numeric array is D check that the input string array is a D column array, and that the number of rows of both input arrays is the same. If any of these checks fail, the function returns the error flag set to true and an error string that describes the error, and also prints the error string to the screen.
Use a for or while loop.
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