0% found this document useful (0 votes)
8 views53 pages

Ders 3

The document provides an overview of basic matrix and vector operations in MATLAB, including the creation of matrices, case sensitivity, and various mathematical operations. It also covers array manipulation techniques such as addition, subtraction, and element-wise operations, as well as functions for statistical analysis. Key commands and examples are given to illustrate the usage of these operations.

Uploaded by

erenkurudere
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)
8 views53 pages

Ders 3

The document provides an overview of basic matrix and vector operations in MATLAB, including the creation of matrices, case sensitivity, and various mathematical operations. It also covers array manipulation techniques such as addition, subtraction, and element-wise operations, as well as functions for statistical analysis. Key commands and examples are given to illustrate the usage of these operations.

Uploaded by

erenkurudere
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/ 53

> A = ones(5,5); 5-by-5 matrix of ones

› B = rand(5,5); 5-by-5 matrix of random values [0,1]


› C = [1 2;3 4]; 2-by-2 matrix
› I = eye(5); 5-by-5 identity matrix
› a = ones(5,1); Column vector of 5 ones
› b = zeros(1,5); Row vector of 5 zeros
› c = 3:7; Row vector [3 4 5 6 7]
› d = [-1 1 4]; Row vector with three values

 Matlab variables are case sensitive,


› Uppercase  matrices
› Lowercase  vectors

› >> e = B(1,2) % Get value in 1st row, 2nd column


 Scalars: single numbers.

 Arrays: more than one number.

 Row and Column Arrays: A row of


numbers

 Two-Dimensional Arrays: called as a


matrix.
The command
b= 1:5
or the command
b = [1:5]
both return a row matrix
 linspace()

 logspace()
› D = B'; Matrix transpose
› e = c'; Vector transpose (row->column)
› D = B+2; Add two 5-by-5 matrices
› D = B-2; Subtract two 5-by-5 matrices
› D = B*2; Multiply two 5-by-5 matrices
› x = B\e; Solve linear equation B*x=e

› e = c.^2; Square each element in vector c
› D = B.*I; Element wise matrix multiplication
› D = I./B; Element wise matrix division
 Dimensions of the matrices and vectors are
still important!!
 Array multiplication .*

 Array division ./

 Array exponentiation .^
 convert to radians.

› First put the values into a matrix.

› Perform the calculation


 For example, in the following session the result y has
the same size as the argument x.
 For example, to compute z = (𝑒 𝑦 sin x) 𝑐𝑜𝑠𝑥 2 , you
must type
 max(x)
 min(x)
 mean(x)
 median(x)
 sum(x)
 prod(x)
 sort(x)
 sortrows(x)
 std(x)
 var(x)

You might also like