Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

for a MATLAB class 2. Consider the problem the MATLAB system has in parsing the string: V=(1 2 3 4; 5,6, 7; 8; 9 10]'

for a MATLAB class

image text in transcribed

2. Consider the problem the MATLAB system has in parsing the string: "V=(1 2 3 4; 5,6, 7; 8; 9 10]' Your task is to use strtok to parse this line and construct the array it represents. You will write a function arrayParse that consumes a string and returns two variables: a string that is the variable name and an array a. Tokenize the string first using '=' as the delimiter to isolate the variable name and the expression to be evaluated. Return the variable name to the user and save the rest of the line as the variable stri for further processing. You may assume that there are no spaces outside the characters [...] b. Tokenize strl with [and] to remove the concatenation operators and save the first token as str2. c. Tokenize str2 using as the delimiter. This will produce 0 or more strings that represent the rows of the array. Save each in the variable rowString. You may assume for now that the first row is the longest one. d. Using nested while loops, tokenize each rowString with ',' and as delimiters and use str2num(...) to extract the numerical value of each array entry. Save it as rowEntry. e. Concatenate the rowentry elements horizontally to produce each row of the array. If the row is too short, pad it with zeros. f. Concatenate each row vertically to produce the resulting array and return that array to the caller. Test the function with cases like: empty=[] row=[1 2 3 4] diag={0 0 0 1; 0 0 1; 0 1; 1]

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

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

Recommended Textbook for

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions