正在加载图片...
ATLAB Lecture 5 School of Mathematical Sciences Xiamen University http∥gdjpkc.xmu.edu.cr ?? Function'sym2poly' is not defined for values of class'char' > syms f4; %define f4 as an symbolic variable >>f4 =sym(2**x+1) assigns the symbolic expression to the variable f4 >> syms x;科4=2*x^2-3*x+1 2*x^23*x+1 > polyvalm(sym2poly(f4),A) compute matrix polynomial 2*A2-3*A+I 21 33 When your expression contains more than one variable, you can specify the variable for which you want to make the substitution >> syms x y >>f5=x2 y+5*sqrt(y) >>subs(f5, x, 3) %substitute the value x=3 in the symbolic expression 9*y+15y^(1/2) > subs(fs, y, 3) %to substitute y=3 ans 3*x^2+5*x*3^(1/2) t Creating a Symbolic Matrix A circulant matrix has the property that each row is obtained from the previous one by cyclically permuting the entries one step forward. You can, using the commands c:baca b %create the circulant matrix a whose elements are a, b, and c [b, c,a [c, a, b] Since a is circulant the sum over each row and column is the same. To check this for the first row and second column enter the command >>sum(A(1,) a+b+c > sum(A(l, ))==sum(A( 2)) This is a logical test to check whether the sum of .. the first row is equal to that of the second row It implies that the sum of the first row is equal to that of the second row. If the answer is 0, it means the sum of the first row is not equal to that of the second row syms alpha beta Lec5-4MATLAB Lecture 5  School of Mathematical Sciences Xiamen University  http://gdjpkc.xmu.edu.cn  Lec5­4  ??? Function 'sym2poly' is not defined for values of class 'char'.  >> syms f4;  %define f4 as an symbolic variable >> f4 =sym('2*x^2 ­ 3*x + 1') % assigns the symbolic expression to the variable f4  or >> syms x; f4 = 2*x^2 ­ 3*x + 1  f4 =  2*x^2 ­ 3*x + 1  >> polyvalm(sym2poly(f4), A) % compute matrix polynomial 2*A^2­3*A+I ans =  12  14  21  33  When your expression contains  more than one variable,  you can specify the variable for which you want to make the substitution.  >> syms x y  >> f5 = x^2*y + 5*x*sqrt(y);  >> subs(f5, x, 3) %substitute the value x = 3 in the symbolic expression  ans =  9*y+15*y^(1/2)  >> subs(f5, y, 3) %to substitute y = 3  ans =  3*x^2+5*x*3^(1/2)  ² Creating a Symbolic Matrix A circulant  matrix  has  the property that  each row is obtained from the previous  one by  cyclically permuting the entries one step forward. You can, using the commands  >> syms a b c >> A = [a b c; b c a; c a b] %create the circulant matrix A whose elements are a, b, and c A =  [ a, b, c ] [ b, c, a ] [ c, a, b ] Since A is circulant, the sum over each row and column is the same. To check this for the first  row and second column, enter the command  >> sum(A(1,:)) ans =  a+b+c >> sum(A(1,:)) == sum(A(:,2)) % This is a logical test to check whether the sum of …  the first row is equal to that of the second row.  ans =  1  It implies that the sum of the first row is equal to that of the second row. If the answer is 0, it means the sum of the first row is not equal to that of the second row.  >> syms alpha beta;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有