0% found this document useful (0 votes)
18 views13 pages

Xdương Văn Hải - 2018600865

The document contains a series of MATLAB code snippets demonstrating polynomial operations, including evaluation, finding roots, multiplication, division, differentiation, and plotting. It showcases the use of functions like polyval, roots, conv, deconv, and polyder with various polynomial inputs. Additionally, it includes visualizations of polynomial functions and their products using mesh and plot commands.

Uploaded by

Phùng Văn Duy
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)
18 views13 pages

Xdương Văn Hải - 2018600865

The document contains a series of MATLAB code snippets demonstrating polynomial operations, including evaluation, finding roots, multiplication, division, differentiation, and plotting. It showcases the use of functions like polyval, roots, conv, deconv, and polyder with various polynomial inputs. Additionally, it includes visualizations of polynomial functions and their products using mesh and plot commands.

Uploaded by

Phùng Văn Duy
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/ 13

Bai 1:

>> p= [10 0 0 12 9 0 -2 105];

>> v=polyval(p,2.8)

v=

1.4527e+04

Bai 2;

>> y=[14 0 0 0 0 12 9 0 -2 10]

y=

14 0 0 0 0 12 9 0 -2 10

>> r=roots(y)

r=

-1.0093 + 0.0000i

-0.7213 + 0.5763i

-0.7213 - 0.5763i

-0.1804 + 1.0689i

-0.1804 - 1.0689i

0.9165 + 0.5216i

0.9165 - 0.5216i

0.4898 + 0.6288i

0.4898 - 0.6288i
Bai 3
thuong 2 da thuc
q=input('Nhap da thuc q= ');
p=input('Nhap da thuc p= ');
w=conv(q,p);%tich 2 da thuc
disp (['tich 2 da thuc: ', num2str(w)])

>> bai3

Nhap da thuc q= [4 0 0 -5 -42 -2]

Nhap da thuc p= [2 -70 -9]

tich 2 da thuc: 8 -280 -36 -10 266 2981 518 18

>> [Q,R]=deconv(q,p) %thuong 2 da thuc

Q=

1.0e+04 *

0.0002 0.0070 0.2459 8.6378

R=

1.0e+06 *

0 0 0 0 6.0685 0.7774

Bai4
%daohamqpvatich
q=input('Nhap da thuc q= ');
p=input('Nhap da thuc p= ');
dq=polyder(q);%daohamq
dp=polyder(p);%daohamp
dqp=polyder(q,p)%daohamtich
disp (['daohamq= ', num2str(dq)])
disp (['daohamp= ', num2str(dp)])
disp (['daohamtichqp= ', num2str(dqp)])
>> daohamqpvatich

Nhap da thuc q= [4 0 0 -5 -42 -2]

Nhap da thuc p= [2 -70 -9]

dqp =

56 -1680 -180 -40 798 5962 518

daohamq= 20 0 0 -10 -42

daohamp= 4 -70

daohamtichqp= 56 -1680 -180 -40 798 5962 518

>> [a,b]=polyder(q,p)% Dao ham thuong hai da thuc

a=

24 -1120 -180 0 434 98 238

b=

4 -280 4864 1260 81

Bai 5

VE DO THI q

>> s=linspace(1,30,30)

s=

Columns 1 through 13
1 2 3 4 5 6 7 8 9 10 11 12 13

Columns 14 through 26

14 15 16 17 18 19 20 21 22 23 24 25 26

Columns 27 through 30

27 28 29 30

>> y=4*s.^5-5*s.^2-42*s-2

y=

Columns 1 through 6

-45 22 799 3846 12163 30670

Columns 7 through 12

66687 130414 235411 399078 643135 994102

Columns 13 through 18

1483779 2149726 3035743 4192350 5677267 7555894

Columns 19 through 24

9901791 12797158 16333315 20611182 25741759 31846606


Columns 25 through 30

39058323 47521030 57390847 68836374 82039171 97194238

>> plot(s,y)

Ve do thi p

>> s=linspace(1,30,30)

s=

Columns 1 through 13

1 2 3 4 5 6 7 8 9 10 11 12 13

Columns 14 through 26

14 15 16 17 18 19 20 21 22 23 24 25 26
Columns 27 through 30

27 28 29 30

>> y = 2*s.^2 - 70*s - 9

y=

Columns 1 through 13

-77 -141 -201 -257 -309 -357 -401 -441 -477 -509 -537 -561 -581

Columns 14 through 26

-597 -609 -617 -621 -621 -617 -609 -597 -581 -561 -537 -509 -477

Columns 27 through 30

-441 -401 -357 -309

>> plot(s,y)
Ve do thi q*p

>> y=8*s.^7-280*s.^6-36*s.^5-10*s.^4+266*s.^3+2981*s.^2+518*s+18

y=

1.0e+10 *

Columns 1 through 8

0.0000 -0.0000 -0.0000 -0.0001 -0.0004 -0.0011 -0.0027 -0.0058

Columns 9 through 16

-0.0112 -0.0203 -0.0345 -0.0558 -0.0862 -0.1283 -0.1849 -0.2587

Columns 17 through 24
-0.3526 -0.4692 -0.6109 -0.7793 -0.9751 -1.1975 -1.4441 -1.7102

Columns 25 through 30

-1.9881 -2.2668 -2.5309 -2.7603 -2.9288 -3.0033

>> plot(s,y)

Ve do thi q/p

>> s=linspace(1,30,30)

s=

Columns 1 through 13

1 2 3 4 5 6 7 8 9 10 11 12 13

Columns 14 through 26
14 15 16 17 18 19 20 21 22 23 24 25 26

Columns 27 through 30

27 28 29 30

>> y=(4*s.^5-5*s.^2-42*s-2)./(2*s.^2 - 70*s - 9)

y=

1.0e+05 *

Columns 1 through 8

0.0000 -0.0000 -0.0000 -0.0001 -0.0004 -0.0009 -0.0017 -0.0030

Columns 9 through 16

-0.0049 -0.0078 -0.0120 -0.0177 -0.0255 -0.0360 -0.0498 -0.0679

Columns 17 through 24

-0.0914 -0.1217 -0.1605 -0.2101 -0.2736 -0.3548 -0.4589 -0.5930

Columns 25 through 30

-0.7674 -0.9962 -1.3014 -1.7166 -2.2980 -3.1454


>> plot(s,y)

Ve do thi z=

>> x=linspace(1,30,30)

x=

Columns 1 through 13

1 2 3 4 5 6 7 8 9 10 11 12 13

Columns 14 through 26

14 15 16 17 18 19 20 21 22 23 24 25 26

Columns 27 through 30
27 28 29 30

>> z=x.*exp(-x.^2-x+1)

z=

Columns 1 through 8

0.3679 0.0135 0.0001 0.0000 0.0000 0.0000 0.0000 0.0000

Columns 9 through 16

0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000

Columns 17 through 24

0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000

Columns 25 through 30

0.0000 0.0000 0 0 0 0

>> plot(x,z)
Bai 6

>> [X1,X2] = ndgrid(-5:.1:5, -5:.1:5);

Z = X1 .* exp(-X1.^2 - X2.^2);

mesh(Z)

You might also like