Matlab Array and Matrix Manipulation 1 Given x 5 1 3 7 2 8

Matlab Array and Matrix Manipulation

1. Given x = [5 1 3 7 2 8 6], explain what the following commands \"means\" by summarizing the net result of the command.

a. x(4)

b. x(1:7)  

c. x(1:end)  

d. x(1:end-1)  

e. x(6:-2:1)  

f. x([1 6 2 1 1])  

g. sum(x)   

2. Given the array A = [ 2 4 1 ; 6 7 2 ; 3 5 9], provide the commands needed to

a. calculate the determinant of A  

b. show the transpose of A  

c. Calculate the trace of A  

d. compute the sum over the rows of A

3. Given the arrays x = [1 4 8], y = [2 1 5] and A = [3 1 6 ; 5 2 7], determine which of the following statements will correctly execute and provide the result. If the command will not correctly execute, state why it will not. Using the command MATLAB whos may be helpful here.
    
a. x + y  

b. x + A  

c. x\' + y  

d. A - [x\' y\']  

e. [x ; y\']  

f. [x ; y]  

g. A - 3

Solution

1)

a. x(4) is the 4th element of x

x(4)=7;

b. x(1:7) is the group of elements of x from x(1) to x(7)

x(1:7)=[5 1 3 7 2 8 6]

c. x(1:end) is the group of total elements of x

x(1:end)=[5 1 3 7 2 8 6]

d. x(1:end-1) is the group of total elements of x except last one

x(1:end-1)=[5 1 3 7 2 8]

e. x(6:-2:1) is the series as [x(6) x(6-2) x(6-2-2)]

x(6:-2:1)=[8 7 1]

f. sum(x) it is the sum of all elements

sum(x)=32

2)

a. det(A)

b. A\'

c. trace(A)

d. sum(a(1,:));

sum(a(2,:));

sum(a(3,:));

3)

a. x+y=[3 5 13]

b. x+A=not possible (matrix dimensions are not equal)

c. x\'+y=not possible (matrix dimensions are not equal)

d. x\'y\' is not possible(3*1,3*1 matrices can not be multiplied)

e. [x;y\'] is not possible(no of columns must be equal for x, y\')

f. [x;y]=[1 4 8

2 1 5]

g. A-3 means subtracting each element of A with 3

A-3= [0 -2 3

2 -1 4]

Matlab Array and Matrix Manipulation 1. Given x = [5 1 3 7 2 8 6], explain what the following commands \
Matlab Array and Matrix Manipulation 1. Given x = [5 1 3 7 2 8 6], explain what the following commands \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site