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

this is the code i have so far. I think its correct but im not sure. clc; clear;

ID: 3912169 • Letter: T

Question

this is the code i have so far. I think its correct but im not sure.

clc; clear; clear all;
A = [1 5 7; 3 6 2; 0 8 2; 8 2 9]


[row col] = ind2sub(size(A), 7)

this is my code for this, i think its correct also, but im not sure.

clc; clear; clear all;
A = [1 5 7; 3 6 2; 0 8 2; 8 2 9]
A(3,3)

and i had next to no idea how to do this one. not sure how to move specific columns and rows.

veri tie irixA A [1 57, 362,082, 829 Give the pair of indices corresponding to the 7th element in this matrix. Enter your MATLAB code in the space provided.

Explanation / Answer

% code

A = [1 5 7; 3 6 2; 0 8 2; 8 2 9]

% part 1
[row col] = ind2sub(size(A), 7)

% output

A =

1 5 7
3 6 2
0 8 2
8 2 9

row = 3
col = 2

% code

A = [1 5 7; 3 6 2; 0 8 2; 8 2 9]

% part 2: 3, 3 are the row and column at which we wanted to find linear index
linearIndex = sub2ind(size(A), 3, 3)

% output

A =

1 5 7
3 6 2
0 8 2
8 2 9

linearIndex = 11

% code

A = [1 5 7; 3 6 2; 0 8 2; 8 2 9]

% part 1
[row col] = ind2sub(size(A), 7)

% output

A =

1 5 7
3 6 2
0 8 2
8 2 9

row = 3
col = 2

% code

A = [1 5 7; 3 6 2; 0 8 2; 8 2 9]

% part 2: 3, 3 are the row and column at which we wanted to find linear index
linearIndex = sub2ind(size(A), 3, 3)

% output

A =

1 5 7
3 6 2
0 8 2
8 2 9

linearIndex = 11