Introduction to MATLAB. Introduction to MATLAB. Dr. Hiren D. Joshi Department of Computer Science Rollwala Computer Centre Gujarat University. What is MATLAB?.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Introduction to MATLAB
Introduction to MATLAB
Dr. Hiren D. Joshi
Department of Computer Science
Rollwala Computer Centre
Gujarat University
+ 1/5 + 1/6
Try It!
At the Command Prompt, type the following commands (press Enter after each):
>> 25/5
>> 5^2
>> 25 + 5
>> sqrt(25)
MATLAB uses the standard order of operations:
- Parentheses - Exponentiation - Division / Multiplication - Addition / Subtraction
Tip: use your up-arrow key to bring back lines
you have already typed. Press ESC to quit the edit.
Try It!
To see this, at the Command Prompt (>>), type the following:
>> ans [press Enter]
>> x [press Enter]
Try It!
At the Command Prompt (>>), type the following:
>> clc [press Enter]
Nice and clean!
Try It!
At the Command Prompt (>>), type the following:
>> matrix = ones(1000) [press Enter]
>> matrix = ones(1000);
>> whos
Try It!
Try It!
Try It!
Ex. Lookfor inverse
>> which sinX
1 2
3 4
5 6
This is a 3 X 2 matrix containing 6 elements
B = [1 2 3 4]This is a 1 X 4 array containing 4 elements, known as a
row vector
C =
1
2
3
This is a 3 X 1 array containing 3 elements, known as a
Column vector
A(2,1) = 3 and C(2) = 2
[1,2,3
4,5,6] =
[ ] This expression contains an empty array, which contains no rows and no columns.
Note that this is not the same as an array containing zeros.
The number of elements in every row of an array must be the same, and the number of elements in every column must be the same.
number of rows and columns in arr.
>> whos c
>> c
1 2 3
4 5 6
7 8 9
10 11 12
b
a
Layout of values
In memory for
Array a.
Data Values for array a.
17.221 -9.5946 +2.3736
where filename is the name of a file in which variables are saved.
1.233.146.28
-5.170
load –mat x.dat
1. the double class (data type).
2. The class is called uint8 which assigns an integer between 0 and 255 to represent the brightness of a pixel.
A = IMREAD(FILENAME,FMT) reads a grayscale or color image from the file specified by the string FILENAME, where the string FMT specifies the format of the file.
i=imread('pout.tif')
imread('C:\Users\Public\Pictures\Sample Pictures\Autumn Leaves.jpg','jpg')
24-bit displays, or 64 gray levels on other systems.
IMWRITE(A,FILENAME,FMT) writes the image A to the file specified by FILENAME in the format specified by FMT.
imwrite(i,'myimg','jpg');
imwrite(i2,'myimg.png')
INFO = IMFINFO(FILENAME,FMT) returns a structure whose fields contain information about an image in a graphics file.
FILENAME is a string that specifies the name of the graphics file, and FMT is a string that specifies the format of the file.
The file must be in the current directory or in a directory on the MATLAB path.
If IMFINFO cannot find a file named FILENAME, it looks for a file named FILENAME.FMT.
imfinfo('myimg.png')
Surf command is used to create a surface display of the block processing approximation
K = imadjust(I,[0.3 0.7],[]);
imview(K)