5. Creating the Matrix & Multiplication
In MATLAB, you create a matrix by entering elements in each row as comma or space
delimited numbers and using semicolons to mark the end of each row.
Matlab code for Matrix Creation
a = [ 1 1 1; 2 2 2;] Matlab code for multiplication
a = 1 1 1 a = [ 1 1 1; 2 2 2;] ;
2 2 2 b= [ 1 1 1; 2 2 2;] ;
c=a*b;
disp(c);
6. Element wise Multiplication
● For element-wise multiplication dot(.) operator is used to perform operation.
>> a=5;
>>b=6;
>>c=a.*b;
>>disp(c);
8. Relational Operator
● Relational operator is used to perform relation of two numerical numbers that
perform some assignment operations.
Creating Unit Impulse signal using relational operator
>>t=-5:1:5;
>>impulse=t==0;
>>plot(t,impulse);
10. Logical Operator
● Logical operator do operation same like AND, OR, NOT gate operations.
Short circuited AND
>>a=5;
>>b=5;
>>c=(a==5)&&(b~=5)
>>False
Short circuited OR
>>a=5;
>>b=5;
>>c=(a==5)||(b~=5)
>>True
In short circuit AND produces 0*1 = FALSE, 1*1 = TRUE (same like AND operation)
In short circuit OR produces 0+1= TRUE also 1+1 = TRUE (same like OR operation)
11. Basic program of multiplication of two signals
● Multiplication of decaying exponential and sine-signal using matlabclear all;
close all;
t=0:0.01:100;
a=exp(-2*t);
b=cos(2*3.14*1*t);
c=a.*b;
subplot(3,1,1)
plot(t,a);
title('decaying exponential');
xlabel('time');
ylabel('amplitude');
subplot(3,1,2)
plot(t,b);
title('sine singnal');
xlabel('time');
ylabel('amplitude');
subplot(3,1,3)
plot(t,c);
title('Multiplication of two signal');
xlabel('time');
ylabel('amplitude');