Problems Ch.2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

CHAPTER 2 SOLUTIONS

2.1 What is the output when the following commands are implemented?

A = [1:3;2:2:6;3:−1:1]

A = A'

A(:,3) = []

A = [A(:,1) [4 5 7]' A(:,2)]

A = sum(diag(A))

Solution

>> A = [1:3;2:2:6;3:−1:1] >> A = A' >> A(:,3) = []


A= A= A=
1 2 3 1 2 3 1 2
2 4 6 2 4 2 2 4
3 2 1 3 6 1 3 6

>> A = [A(:,1) [4 5 7]' A(:,2)] >> A = sum(diag(A))


A= A=
1 4 2 12
2 5 4

3 7 6

MOHAMMED HASANIYAH 1

You might also like