Vous êtes sur la page 1sur 8

# LAB N0 1

1. This command assign value to variable.

>> a=5

a=

>> b=11

b=

11

2. This command generates a row vector from 5 to 11.

>> (a:b)

ans =

5 6 7 8 9 10 11

3. This command generates a row vector from 5 to 11 with difference of 2 between each value.

>> (a:2:b)

ans =

5 7 9 11

4. This command generates a row vector of points between 10*a and 10*b.

>> logspace(a,b)

ans =

1.0e+11 *

Columns 1 through 12
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0.0000 0.0000

Columns 13 through 24

0.0000 0.0000 0.0001 0.0001 0.0001 0.0001 0.0002 0.0002 0.0003 0.0004
0.0005 0.0007

Columns 25 through 36

0.0009 0.0012 0.0015 0.0020 0.0027 0.0036 0.0047 0.0063 0.0083 0.0110
0.0146 0.0193

Columns 37 through 48

0.0256 0.0339 0.0450 0.0596 0.0791 0.1048 0.1389 0.1842 0.2442 0.3237
0.4292 0.5690

Columns 49 through 50

0.7543 1.0000

5. This following command generates a row vector of 3 points between decades 10*a and 10*b

>> logspace(a,b,3)

ans =

1.0e+11 *

0.0 0.0010 1.0000

6. This command generates a row vector of 100 value between 5 and 11 linearly spaced.

>> linspace(a,b)

ans =

Columns 1 through 12
5.0000 5.0606 5.1212 5.1818 5.2424 5.3030 5.3636 5.4242 5.4848 5.5455
5.6061 5.6667

Columns 13 through 24

5.7273 5.7879 5.8485 5.9091 5.9697 6.0303 6.0909 6.1515 6.2121 6.2727
6.3333 6.3939

Columns 25 through 36

6.4545 6.5152 6.5758 6.6364 6.6970 6.7576 6.8182 6.8788 6.9394 7.0000
7.0606 7.1212

Columns 37 through 48

7.1818 7.2424 7.3030 7.3636 7.4242 7.4848 7.5455 7.6061 7.6667 7.7273
7.7879 7.8485

Columns 49 through 60

7.9091 7.9697 8.0303 8.0909 8.1515 8.2121 8.2727 8.3333 8.3939 8.4545
8.5152 8.5758

Columns 61 through 72

8.6364 8.6970 8.7576 8.8182 8.8788 8.9394 9.0000 9.0606 9.1212 9.1818
9.2424 9.3030

Columns 73 through 84

9.3636 9.4242 9.4848 9.5455 9.6061 9.6667 9.7273 9.7879 9.8485 9.9091
9.9697 10.0303

Columns 85 through 96

10.0909 10.1515 10.2121 10.2727 10.3333 10.3939 10.4545 10.5152 10.5758


10.6364 10.6970 10.7576

Columns 97 through 100

10.8182 10.8788 10.9394 11.0000

7. This command generates a row vector of 7 value between 5 and 11 linearly spaced.

>> linspace(a,b,7)
ans =

5 6 7 8 9 10 11

8. Semi colon is use to not show the output on the screen.

>> a-b

ans =

-6

9. This command rounds value toward zero side.

>> a=5.778

a=

5.7780

>> fix(a)

ans =

10. This command rounds value toward +ve nearest integer.

>> ceil(a)

ans =

11. 10. This command rounds value toward -ve nearest integer.

>> floor(a)
ans =

12. This command rounds of value .

>> round(a)

ans =

13. This command is used to find the remainder of algebraic division

>> rem(a,b)

ans =

5.7780

14. This command is used to find the remainder of algebraic division and find its modulus.

>> mod(a,b)

ans =

5.7780

15. This command is used to find factorial of number .

>> factorial(b)

ans =

39916800
16. this command is used to find the absolute value of a vector.

>> abs(a)

ans =

5.7780

17. This command is used to find square root of a number.

>> sqrt(b)

ans =

3.3166

18. This command is used to show the number in long form .

>> format long

>> pi

ans =

3.141592653589793

19. This command is used to show the number in short form.

>> format short

>> pi

ans =

3.1416

20. This command is used to show the variable name of the program.

>> who
Your variables are:

21. a ans b

Name size bytes class attributes

a 1x1 8 double

ans 1x1 8 double

b 1x1 8 double

22. % sign is used for command in MATLAB.

23. clc command is used to clean the screen command window.

24. Clear command is used to clear all the variable.

25. Clear (variable name) command is used to clear the desire variable only.

26. This command is used to generate a 1x1 matrix of random values.

>> rand

ans =

0.8147

27. This command is used to generate a 2x2 matrix of random value.

>> rand(2)

ans =

0.1270 0.6324

0.9134 0.0975

28. This command is used to generate a 1x1 matrix of a random intrgers.

>> randn
ans =

-0.4336

29 help variable name is used to show the related used of variable.

30 look for is used to find every place where the variable or command is present.

31 exit command is used to exit the MATLAB software.

32 quit command is used to stop the running of program.

33. MATLAB has some predefined variable like pi, ans,I and j.

>> i

ans =

0.0000 + 1.0000i

Vous aimerez peut-être aussi