-
Notifications
You must be signed in to change notification settings - Fork 1
/
Simulation_lab_1.m
100 lines (51 loc) · 1.04 KB
/
Simulation_lab_1.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
a=floor(6.3) %Greatest Integer Function
b=ceil(6.3) %Least Integer Function
c=round(6.3) %Round Off Function
%================Question===============
A=[1 3 9;5 10 7;6 8 2]
% Question 1-----------
size(A) % Function to find size of Matrix A
% Question 2-----------
transpose(A) % Finding tranpose matrix of A
% Question 3-----------
sum(A) % To get sum of each row of Matrix A
% Question 4-----------
prod(A) % Finding Product of Each Element of row
% Question 5-----------
B=rand(3,3)*10
ceil(B)
% Question 6-----------
A-B
% Question 7-----------
A*B
% Question 8-----------
A*eye(3,3)
% Question 9-----------
arr=[1:8]
% Question 10----------
for i=1:10
fprintf("5 * %d = %d\n",i,i*5)
end
% Question 11----------
t=1:0.1:4*pi;
x=5*sin(t);
plot(t,x)
% Question 12-----------
for num=1:10
if num<5
num*2
end
if num>5
num*5
end
end
% Question 13-----------
x=20:30;
y=x.^2 + 2*x +5
% Question 14-----------
zeros(3,3)
% Question 15-----------
ones(4,4)
% Question 16-----------
a1=A(1,:)
a2=A(2,:)