Professional Documents
Culture Documents
Matlab Notes
Matlab Notes
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
b=
1 4 7 10 13 16 19 22 25 28
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