You are on page 1of 4

1. We write code in command window.

2. Command history can be accessed by pressing the upper arrow key.


3. All the variables are stored in the workspace.
4. Workspace is an excel file.
5. If no variable is assigned then the value is assigned to the default variable ans.
6. A and a is not same, different values can be stored in both variables.
7. If the programs are saved in the default directory i.e., C drive then the execution process will
take time. Change the directory of saving the programs.
8. MATLAB is not a software it’s an API.
9. %% is used for commenting the code.
10. Most commonly double and char is used for numbers with two precision points and
characters respectively.

11. To check the datatype of a variable class can be used. class(x)


12. x is used to clear command window, clear all to clear workspace
13. difference between matrix and array, array is matrix with only one row.
14. Array is a vector.
15. Relation operator
a. a= 5 b=8
if a < b
a=a+b
end
13
b. >> if x == y
disp('Ttue')
else
disp('False')
end
False

16. Array from 1 to 50


>> a = [1:50]

a=

Columns 1 through 22

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
22

Columns 23 through 44

23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
42 43 44

Columns 45 through 50

45 46 47 48 49 50

17. Array from 1 to 30 with gap of 3


>> b = [1 : 3 : 30]

b=

1 4 7 10 13 16 19 22 25 28

18. Descending order array


>> f = [6:-1:1]

f=

6 5 4 3 2 1
19. In MATLAB only one special character is present i.e., pi
>> pi

ans =

3.1416
For other special characters values need to be assigned. We can also reassign the value of pi

20. >> a= 15 + 6i

a=

15.0000 + 6.0000i
>> b = 8 + 1i

b=

8.0000 + 1.0000i

>> c = a+b

c=

23.0000 + 7.0000i

>> real(c)

ans =

23

>> imag(c)

ans =

>> abs(b)

ans =

8.0623

21. If you don’t want to show the ans every time after assigning values to the variable then use
semicolon (;)
>> a= 50;
>> b=7;
>> c = a + b

c=

57
22. For scalar square 5^2 can be used instead of .^ which is used for squaring array
23. Indexing
>> a = [4 6 7 8 9]

a=
4 6 7 8 9

>> c = a(3)

c=

7
24. Value in trigonometric functions is in radians

You might also like