% 自变量用'a表示'
% 如果多项式是数字则choice=1
regexp_poly_example('1',1)
ans =
1
regexp_poly_example('1000',1)
ans =
1000
% 多项式最大阶数是1阶choice=2
% 如果在choice=2的选择里面(只有一阶的式子)出现了choice=1就显示出错
regexp_poly_example('a+1',1)
你的输入出现了错误
ans =
NaN
regexp_poly_example('a+1',2)
ans =
1 1
regexp_poly_example('2*a+1',2)
ans =
2 1
regexp_poly_example('-a',2)
ans =
-1 0
regexp_poly_example('-a-1',2)
ans =
-1 -1
regexp_poly_example('a',2)
ans =
1 0
regexp_poly_example('5*a',2)
ans =
5 0
regexp_poly_example('5*a+4',2)
ans =
5 4
% choice=3,即出现了^的标准,意味着多项式有2阶3阶的
regexp_poly_example('a^2',3)
ans =
1 0 0
regexp_poly_example('a^2-a',3)
ans =
1 -1 0
regexp_poly_example('a^2-a+1',3)
ans =
1 -1 1
regexp_poly_example('4*a^5+a^2-a+1',3)
ans =
4 0 0 1 -1 1
regexp_poly_example('-a^10-4*a^5+a^2',3)
ans =
-1 0 0 0 0 -4 0 0 1 0 0
regexp_poly_example('-a^12+11*a^6+a^3-a^2-a+1',3)
ans =
-1 0 0 0 0 0 11 0 0 1 -1 -1 1
regexp_poly_example('-a^12+11*a^6+5*a^3-16*a^2-a+1',3)
ans =
-1 0 0 0 0 0 11 0 0 5 -16 -1 1
regexp_poly_example('-a^12+11*a^6+a^3-a^2-a+1',3)
ans =
-1 0 0 0 0 0 11 0 0 1 -1 -1 1
regexp_poly_example('-12*a^13+12*a^10+5*a^6+11*a^4-16*a^2-a+1',3)
ans =
-12 0 0 12 0 0 0 5 0 11 0 -16 -1 1
regexp_poly_example('12*a^13+12*a^10+5*a^6+11*a^4-16*a^2-a+1',3)
ans =
12 0 0 12 0 0 0 5 0 11 0 -16 -1 1
regexp_poly_example('a^13+12*a^10+5*a^6+11*a^4-16*a^2-a+1',3)
ans =
1 0 0 12 0 0 0 5 0 11 0 -16 -1 1