Answered step by step
Verified Expert Solution
Link Copied!

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 text/string data. Consider the following table showing the number of silicon wafers processed by three semiconductor manufacturers over four consecutive quarters:
Q1 Q2 Q3 Q4
Intel 10000110001900015000
TSMC 21000250002400029000
Global Foundries 75001020099009800
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"; ]%1D string column array
foundryList =3\times 1 string
"Intel"
"TSMC"
"Global Foundries"
numWafers =[10000,11000,19000,15000;
21000,25000,24000,29000;
7500,10200,9900,9800; ]%2D numeric array
numWafers =3\times 4
10000110001900015000
21000250002400029000
75001020099009800
Note that the 1D string column array has the same number of rows as the 2D 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 (1) the largest number of wafers processed, (2) all the quarterly wafer numbers greater than 15000,(3) the foundry with the fewest wafers processed in any given quarter, and (4) 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 ]= MyProblemFunction(numWafers,foundryList)
maxNumWafers =29000
largeNumWafers =5\times 1
19000
21000
25000
24000
29000
foundryMinWafers = "Global Foundries"
foundryMaxWafers ="TSMC"
errResult = logical
0
errString =""
In this miniproject, you will define your own tabular data problem that uses a 2D numeric array and a 1D string column array to represent the data, and you will solve that problem with a custom function using the template below. The 2D numeric array and 1D string column array are inputs to your function. Your custom function must:
Return seven results: (1) a numeric scalar result based on the data in the 2D numeric array, (2) a numeric array result based on the data in the 2D numeric array, (3) and (4) two string scalar results from the input 1D string column array based on the data in the 2D numeric array, (5) a logical scalar error result (error flag),(6) a scalar error string result, and (7) a table constructed from the input 1D string column array as the first table column and the 2D numeric array as the remaining table columns.
Perform the following input data checks: (1) check that the input arguments are the correct type, (2) check that the input numeric array is 2D,(3) check that the input numeric array is 2D,(4) check that the input string array is a 1D column array, and (5) 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

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions