Homework Matlab
Homework Matlab
Id: e20180899
Homework: 01
Problem:
Given three of row vectors 𝑎 = (5, 3, 7, 10, 15, 17) 𝑏 = (4, 2, 5, 7,19, 0) and 𝑐 = (1, 5, 3, 8).
1. Change these row vectors to column vectors 𝑎 ′, 𝑏 ′ and c ′ respectively by using MATLAB commands.
2. Calculate the product of ‘a’ and ‘b’ then verify your answer using MATLAB commands.
3. Calculate the Cumulative of vector c and verify with MATLAB commands.
4. Sorting the vector ‘a’ and ‘b’ using MATLAB commands. After that, calculate its dot product and verify
using two technics in MATLAB.
Solution:
1. Change these row vectors to column vectors 𝑎 ′, 𝑏 ′ and c ′ respectively by using MATLAB commands.
We have three of row vectors 𝑎 = (5, 3, 7, 10, 15, 17) 𝑏 = (4, 2, 5, 7,19, 0) and 𝑐 = (1, 5, 3, 8).
Thus:
Commands Results Comments
a’=[5; 3; 7; 10; 15; 17] a’=
10
15
17
𝑏’= [4; 2; 5; 7; 19; 0] b’=
19
0
c’= [1; 5; 3; 8] c’=
2. Calculate the product of ‘a’ and ‘b’ then verify your answer using MATLAB commands.
5 4 9
3 2 5
7 5 12
a+b = + =
10 7 17
15 19 34
(17) ( 0 ) (17)
Commands Results Comments
4. Sorting the vector ‘a’ and ‘b’ using MATLAB commands. After that, calculate its dot product and verify using
two technics in MATLAB.
Commands Results Comments