Professional Documents
Culture Documents
I
Assignment 2 — 2nd Semester 2023-2024
1. (8 points) Check the output and explain the following commands in OCTAVE:
(i) [1 : 4; 5 : 8] and [1 : 4, 5 : 8]
(ii) [10, 12; 13, 14] ∗ eye(2)
(iii) [1, 2; 3, 4]. ∧ 3 and [1, 2; 3, 4] ∧ 3
(iv) disp(ones(3)) and disp ones(3)
(v) x = −3 : 3, x(0), x(1), x[0], ansd x[1]
(vi) x(2, :) and x(:, 2) if x = reshape(1 : 9, 3, 3)
(vii) linspace(1, 10, 80) and logspace(1, 4, 4)
(viii) sin(π) and sin(10000π)
2. (8 points) Use linspace function to create vectors identical to those obtained with the
statements that follow. Use multiple statements where necessary. Write a command
that will test if the vector you produced and the vector given below are equal.
(i) x = 0 : 10
(ii) x = 0 : 0.2 : 10
(iii) x = −12 : −12
(iv) x = 10 : −1 : 1
11 5
3. (8 points) Given the matrix C = 2 1, write two OCTAVE statements to create
18 7
the column vectors u = (11, 2, 18) and v = (5, 1, 7)T by extracting the columns of C.
T
Write OCTAVE statements to compute the inner product of the vectors u and v, and
the transpose of C.
5. (8 points) Plot (separately) the functions sin θ, cos θ for 50 points in [0, 2π]. Connect
the points with a dashed line and create a x-axis label θ and y-axis label sin(θ). Do the
same for the function log x, exp(x) for 100 points in [0.01, 3].