0% found this document useful (0 votes)
41 views2 pages

CSC567 - Exercise 0

This document introduces exercises in MATLAB for vectors and matrices. It contains 6 exercises to practice basic MATLAB commands for manipulating matrices and vectors, including adding, subtracting, multiplying matrices, extracting rows and columns, computing sums, and more. The exercises can be solved using single MATLAB commands or short scripts.

Uploaded by

feyrs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views2 pages

CSC567 - Exercise 0

This document introduces exercises in MATLAB for vectors and matrices. It contains 6 exercises to practice basic MATLAB commands for manipulating matrices and vectors, including adding, subtracting, multiplying matrices, extracting rows and columns, computing sums, and more. The exercises can be solved using single MATLAB commands or short scripts.

Uploaded by

feyrs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Exercise 0: Introduction to MATLAB

Finish reading all sections of Tutorial 1-Vector and Matrices. Then do the exercises below. Many
of the exercises can be answered by a single MATLAB command. If the command is too
complicated, or plotting is required, use more lines.

1. Enter the two matrices

2. Try the following and ensure you can follow what is happening.

a. A+5
b. A+B
c. A-B
d. A*B
e. A^2
f. A'

3. Create a row vector of the even integers between 8 and 12 inclusive.

4. Let x = [2 5 1 6].

a. Add 16 to each element


b. Add 3 to just the odd-index elements
c. Compute the square root of each element
d. Compute the square of each element

5. Let x = [3 1 5 7 9 2 6]. For each of the following commands first think about what the result
should be and then type the command and verify your answer.

a. x(3)
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)

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

a. Assign the first row of A to a vector called x1


b. Assign the last 2 rows of A to an array called y
c. Compute the sum over the columns of A
d. Compute the sum over the rows of A

You might also like