第一題
Find the multiplication result of two polynorminals,
in which p=133x^5+122x^3+1, q=2x^4+100x^2+1
程式碼
p=[133 0 122 0 0 1];
q=[2 0 100 0 1];
ans1=conv(p,q)
結果
ans1 =
266 0 13544 0 12333 2 122 100 0 1
即為266x^9+13544x^7+12333x^5+2x^4+122x^3+100x^2+1
第二題
A polynorminal is defined as f=100x^3+23x^2+x+45
Find the value f(x) if x is a magic matrix in the order of 5
程式碼
f=[100 23 1 45];
x=magic(5);
ans2=polyvalm(f,x)
結果
ans2 =
5830132 5825724 5059176 5210878 5633875
5824573 5332275 5196252 5496574 5710111
5206104 5074326 5518893 5949340 5811122
5310105 5521572 5826264 5702291 5199553
5388871 5805888 5959200 5200702 5205124
第三題
Using p and q defined in the item 1, find the quotient and residue of p/q
程式碼
p=[133 122 1];
q=[2 100 1];
[s,r]=deconv(p,q)
結果
s =
66.5000 (商)
r =
1.0e+003 *
0 -6.5280 -0.0655 (餘)
第四題
Find the roots of p=0 and q=0, in which both p & q are defined in item 1
程式碼
p=[133 0 122 0 0 1]
q=[2 0 100 0 1]
p=roots(p)
q=roots(q)
結果
p =
-0.0045 + 0.9578i
-0.0045 - 0.9578i
0.1039 + 0.1744i
0.1039 - 0.1744i
-0.1988
q=
0 + 7.0704i
0 - 7.0704i
0 + 0.1000i
0 - 0.1000i
第五題
Fit a polynorminal curve to following data to an order of 3. x=[1:9];
y=[1210, 1866, 2301, 2564, 2724, 2881, 2879, 2915, 3010]
程式碼
x=[1:9]; %應該只有到9
y=[1210 1866 2301 2564 2724 2881 2879 2915 3010] ;
pans=polyfit(x,y,3)
結果
pans =
6.3047 -134.4603 994.3540 350.9127
沒有留言:
張貼留言