0% found this document useful (0 votes)
13 views9 pages

Week3h W

Uploaded by

hein htet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views9 pages

Week3h W

Uploaded by

hein htet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

(1)

>> r= input('Enter radius ')

Enter radius 7

r=

>> A= 0.5*pi*r^2;

>> disp ('Area is ');

Area is

>> disp (A);

76.9690

>> r= input (' Enter radius ')

Enter radius 7

r=

>> A= 0.25*pi*r^2;

>> disp ('Area is ');

Area is

>> disp (A);

38.4845
(2)

>> l= input ('Enter the length of rectangle');

Enter the length of rectangle4

>> b= input ('Enter the width of rectangle');

Enter the width of rectangle2

>> A= l*b;

>> disp ('Area is ');

Area is

>> disp (A);

(3)
>> x = 3;
>> isinteger(x)

ans =

logical

>> isfloat(x)

ans =

logical

>> isvector(x)

ans =

logical

>> isscalar(x)

ans =

logical

>> isnumeric(x)
ans =

logical

x = 23.54
isinteger(x);
isfloat(x);
isvector(x);
isscalar(x);
isnumeric(x);

x=

23.5400

x = [1 2 3]
isinteger(x);
isfloat(x);
isvector(x);
isscalar(x);

x=

1 2 3

x = 'Hello'

>> isinteger(x)

ans =

logical

>> isfloat(x)

ans =

logical

>> isvector(x)

ans =
logical

>> isscalar(x)

ans =

logical

>> isnumeric(x)

ans =

logical

>> str= 'Hello world!';

>> n= 2345;

>> d= double (n)

d=

2345

>> un= uint32(789.50)

un =

uint32

790

>> rn= 5678.92347


rn =

5.6789e+03

>> c= int32(rn)

c=

int32

5679

(4)

>> M= [pi exp(pi); 0 -1]

M=

3.1416 23.1407

0 -1.0000

>> v= [3;4]

v=

>> x= M*v

x=
101.9875

-4.0000

(5)

>> v= input('Enter vector ');

p= dot(v,v);

disp('Dot product (v . v): {p}');

disp (p);

x= sum(p);

disp('Sum of the dot product result: {sum_p} ');

disp(x);

y= size(v);

disp('Size of vector');

disp(y);

T= transpose(v);

disp('Transpose of vector');

disp(T);

q= v.*v.*T;

disp(q);

r=v.*T.*v;

disp(r);

Enter vector [5;6]

Dot product (v . v): {p}

61

Sum of the dot product result: {sum_p}

61
Size of vector

2 1

Transpose of vector

5 6

125 150

180 216

125 150

180 216

(6)

>> w=[1 2 3;4 5 6;7 8 9];

disp('3*3 matrix:');

disp(w);

r=[10 11;12 13;14 15];

disp('3*2 matrix:');

disp(r);

3*3 matrix:

1 2 3

4 5 6

7 8 9

3*2 matrix:

10 11

12 13

14 15
(7)

>> a=[3 27;5 18;8 75;20 40];

disp('4*2 matrix:');

disp(a);

b=[12 13 14;15 16 17];

disp('2*3 matrix:');

disp(b);

4*2 matrix:

3 27

5 18

8 75

20 40

2*3 matrix:

12 13 14

15 16 17

(8)

>> c=[2 3 4 5 6;11 22 33 44 55;23 34 45 56 67;12 13 14 15 16;9 8 7 6 5;9 8 7 6 4; 4 4 4 4 4];

disp('7*5 matrix:');

disp(c);

d=[1 1 4 2 1;5 4 6 3 7;8 12 7 3 19;5 4 0 8 66;3 7 4 9 1];

disp('5*5 matrix:');

disp(d);

7*5 matrix:

2 3 4 5 6

11 22 33 44 55

23 34 45 56 67

12 13 14 15 16
9 8 7 6 5

9 8 7 6 4

4 4 4 4 4

5*5 matrix:

1 1 4 2 1

5 4 6 3 7

8 12 7 3 19

5 4 0 8 66

3 7 4 9 1

You might also like