Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 1 (20 points) (a) Create a cell array cells with the numbers 1 2 3 in th

ID: 3802407 • Letter: P

Question

Problem 1 (20 points)

(a) Create a cell array cells with the numbers 1 2 3 in the 1st row (each in one cell), the vectors [11 12] [12 14] [13 16] in the 2nd row (each in one cell), and the strings 'how' 'are' 'you' in the third row (each in one cell).

(b) In one command, assign the numbers stored in the 1st row of the cell array to a new (numerical) vector containing 3 elements (NOT to a new cell array; check the data type in the Workspace).

(c) In one command, assign the vectors stored in the 2nd row of the cell array to a new (numerical) matrix with 3 rows and 2 columns such that each vector from the cell array is in one row (NOT to a new cell array; check the data type in the Workspace).

Problem 1 (20 points (a) Create a cell array cells with the numbers 1 2 3 in the 1s row (each in one cell), the vectors 11 12 [12 14 I13 161 in the 2nd row (each in one cell), and the strings how are you' in the third row (each in one cell). (b) In one command, assign the numbers stored in the 1st row of the cell array to a new (numerical) vector containing 3 elements (NOT to a new cell array, check the data type in the Workspace (c) In one command, assign the vectors stored in the 2nd row of the cell array to a new (numerical matrix with 3 rows and 2 columns such that each vector from the cell array is in one row (NOT to a new cell array, check the data type in the Workspace). (d) Execute the following commands in the Command Window: cells13, cells (3, and cells13,: J. Explain what each command does and the differences in output between the commands.

Explanation / Answer

Part (a)

>> cells = {{1,2,3};{[11 12],[12 14],[13,16]};{'how','are','you'}}

cells =

{1x3 cell}
{1x3 cell}
{1x3 cell}

Part (b)

>> vect = cell2mat(cells{1})

vect =

1 2 3

Part (c)

>> Mat = cell2mat(cells{2}')

Mat =

11 12
12 14
13 16

Part (d)

>> cells{3,:}

ans =

'how' 'are' 'you'

>> cells(3,:)

ans =

{1x3 cell}

>> [cells{3,:}]

ans =

'how' 'are' 'you'

>>

cells{3,:} and [cells{3,:}] are printed the same result and it is the content in the cells{3}. but cells(3,:) printed the type of the cells{3}.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote