Some Other Functions: Addition, Subtraction, Multiplication, Division, Exponentiation 1) Integer Values: Codes

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

ADDITION, SUBTRACTION, MULTIPLICATION, DIVISION, EXPONENTIATION

1) integer values:
Codes:
a=2
b=3.5
c=a+b
d=a-b
e=a/b
f=a*b
output:
a=2
b=3.5000
c=5.5000
d=-1.5000
e=0.5714
f=7

2) complex value
Code:
a=2+3i
b=4+6i
c=a+b
d=a-b
e=a/b
f=a*b
output:
a = 2.0000 + 3.0000i
b = 4.0000 + 6.0000i
c = 6.0000 + 9.0000i
d =-2.0000 - 3.0000i
e = 0.5000
f = -10.0000 +24.0000i
Some Other Functions
1) Basic functions:
a=[1 2 3 4 -1 -407 2323 ];
b=sin(90);
c=cos(90);
d=tan(90);
e=log(4);
f=log10(5);
g=log2(10);
h=sqrt(4);
i=exp(56);
j=max(a);
k=min(a);
l=abs(a);
m=acos(a);
n=angle(a);
o=asin(a);
p=atan(a);
output:
a = [1 2 3 4 -1 -407 2323]
b =0.8940
c =-0.4481
d = -1.9952
e = 1.3863
f =0.6990
g = 3.3219
h =2
i = 2.0917e+24
j = 2323
k = -407
l = 1 2 3 4 1 407 2323
m = 0.0000 + 0.0000i 0.0000 + 1.3170i 0.0000 + 1.7627i 0.0000 + 2.0634i
3.1416 + 0.0000i 3.1416 - 6.7020i 0.0000 + 8.4438i
n = 0 0 0 0 3.1416 3.1416 0
o = 1.5708 + 0.0000i 1.5708 - 1.3170i 1.5708 - 1.7627i 1.5708 - 2.0634i -
1.5708 + 0.0000i -1.5708 + 6.7020i 1.5708 - 8.4438i
p = 0.7854 1.1071 1.2490 1.3258 -0.7854 -1.

2) complex numbers:
Code:
a=complex(2,3)
b=sqrt(a)
c=real(a)
d=imag(a)
e=abs(a)
f=angle(a)
Output:
a =2.0000 + 3.0000i
b = 1.6741 + 0.8960i
c=2
d=3
e = 3.6056
f = 0.9828
3) zeroes and ones
Code:
a=zeros(3)
b=zeros(3,2)
c=ones(4)
d=ones(2,4)

output:
a=
0 0 0
0 0 0
0 0 0

b=
0 0
0 0
0 0
c=
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
d=
1 1 1 1
1 1 1 1

4) size and length of matrix


Code:
d=[1 2 3 4]
length(d)
size(d)

Output:
d=1 2 3 4
length = 4
size =1 4

You might also like