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

Matlab H.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

Matlab H.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

(2) x=zeros(7,7)

x=

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

>> y=magic(7)

y=

30 39 48 1 10 19 28

38 47 7 9 18 27 29

46 6 8 17 26 35 37

5 14 16 25 34 36 45

13 15 24 33 42 44 4

21 23 32 41 43 3 12

22 31 40 49 2 11 20

z=[x,y]

z =0 0 0 0 0 0 0 30 39 48 1 10 19 28

0 0 0 0 0 0 0 38 47 7 9 18 27 29

0 0 0 0 0 0 0 46 6 8 17 26 35 37

0 0 0 0 0 0 0 5 14 16 25 34 36 45
0 0 0 0 0 0 0 13 15 24 33 42 44 4

0 0 0 0 0 0 0 21 23 32 41 43 3 12

0 0 0 0 0 0 0 22 31 40 49 2 11 20

(3) x1=zeros (5)

x1 =0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

>> x2= ones (5)

x2 =

1 1 1 1 1

1 1 1 1 1

1 1 1 1 1

1 1 1 1 1

1 1 1 1 1

>> z2= [x1, x2]

z2 =

0 0 0 0 0 1 1 1 1 1

0 0 0 0 0 1 1 1 1 1

0 0 0 0 0 1 1 1 1 1
0 0 0 0 0 1 1 1 1 1

0 0 0 0 0 1 1 1 1 1

(1) >> x=0:pi/100:2*pi;

>> y=cos(x);

>> plot(x,y)

>> xlabel('x values');

>> ylabel('y values');

>> title ('cosine plot')


cosine plot
1

0.8

0.6

0.4

0.2
y values

-0.2

-0.4

-0.6

-0.8

-1
0 1 2 3 4 5 6 7
x values
>> x=0:pi/100:2*pi;

>> y=tan(x);

>> plot(x,y)

>> plot(x,y,'r')

>> xlabel('x values');

>> ylabel('y values');

>> title('tan plot')

1015 tan plot


6

0
y values

-2

-4

-6

-8
0 1 2 3 4 5 6 7
x values
>> x=0:pi/100:2*pi;

>> y=cot(x);

>> plot(x,y,'g')

>> xlabel('x values');

>> ylabel('y values');

>> title ('cotagent plot')

1015 cotagent plot


1

-1

-2

-3
y values

-4

-5

-6

-7

-8

-9
0 1 2 3 4 5 6 7
x values
>> x=0:pi/100:2*pi;

>> y=sec(x);

>> plot(x,y,'y')

>> xlabel('x values');

>> ylabel('y values');

>> title ('secant plot')

1015 secant plot


1

-1

-2
y values

-3

-4

-5

-6

-7
0 1 2 3 4 5 6 7
x values
>> x=0:pi/100:2*pi;

>> y=csc(x);

>> plot(x,y,'c')

>> xlabel('x values');

>> ylabel('y values');

>> title ('cosecant plot')

1015 cosecant plot


10

5
y values

-5
0 1 2 3 4 5 6 7
x values
>> x=0:pi/100:2*pi;

>> y=cos(x);

>> plot(x,y,'r-*')

>> hold on

>> y2=tan(x);

>> plot(x,y2,'g--')

>> hold on

>> y3=cot(x);

>> plot(x,y3,'y--')

>> hold on

>> y4=sec(x);

>> plot(x,y4,'b--')

>> hold on

>> y5=csc(x);

>> plot(x,y5,'k--')

>> legend('Cosine','Tangent','Cotangent','Secant','Cosecant')

>> xlabel('x values');

>> ylabel('y values');

>> title ('multiple plot')

>> hold off


1016 multiple plot
1
Cosine
0.8 Tangent
Cotangent
0.6 Secant
Cosecant
0.4

0.2
y values

-0.2

-0.4

-0.6

-0.8

-1
0 1 2 3 4 5 6 7
x values

You might also like