-------------------------TASK 01--------------------------
Matlab stores numeric data as double‐precision floating point by default. To store data as an 8‐ bit integer, int8 (a conversion function) can be used. Type the sample code in matlab command window:
>> x = 26
>> whos
>> y = int8(x)
>> whos
What difference do you see? State your findings.
-------------------------TASK 02--------------------------
Create logical array “x” of 5 elements by entering a true (1) or false (0) value for each element.
-------------------------TASK 03--------------------------
Create an m‐file to get 10 numbers from user and generate the square of those numbers.
Lab # 2
OBJECTIVES OF THE LAB
‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
In this lab, we will cover the following topics:
Built in Matrix Functions
Indexing Matrices
Sub Matrices
Matrix element level operations
Round Floating Point numbers to Integers
‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
MATRICES
MATLAB works with essentially only one kind of object, a rectangular numerical matrix possibly, with complex entries. Every MATLAB variable refers to a matrix [a number is a 1 by 1 matrix]. In some situations, 1‐by‐1 matrices are interpreted as scalars, and matrices with only one row or one column are interpreted as vectors.
A matrix is a rectangular array of numbers. For example:
3
|
6
|
9
|
2
|
1
|
4
|
8
|
5
|
2
|
8
|
7
|
5
|
1
|
4
|
2
|
3
|
defines a matrix with 4 rows, 4 columns, and 16 elements.
Example:
Consider the following three equations:
This family of equations can be written in the form , where
Depending on the specific values of coefficients in matrices A and B, there may be:
no solutions to , or
a unique solution to , or
an infinite number of solutions to In above example, the solution matrix is
Dostları ilə paylaş: |