Add second year
This commit is contained in:
26
second/semester2/CT248/Lecture Files/Lecture04.m
Normal file
26
second/semester2/CT248/Lecture Files/Lecture04.m
Normal file
@ -0,0 +1,26 @@
|
||||
clear;
|
||||
|
||||
A = [1 2 ; 3 4 ];
|
||||
B = eye(2);
|
||||
|
||||
% MATRIX multiplication
|
||||
C = A*B;
|
||||
|
||||
% element-wise multiplication
|
||||
D = A.* B;
|
||||
|
||||
rng(100);
|
||||
rolls = randi([1 6], 1, 10);
|
||||
|
||||
% checking each element of rolls one by one to see which ones are greater than 3
|
||||
gt3 = rolls > 3;
|
||||
rolls(gt3); % filtering rolls to find the values > 3
|
||||
|
||||
A ~= 3;
|
||||
|
||||
% remove duplicates from rolls
|
||||
unique(rolls)
|
||||
|
||||
for i = rolls
|
||||
disp(i)
|
||||
end
|
Reference in New Issue
Block a user