📄 example_mpoly.m
字号:
% Example calls to subroutines in @mpoly
% Copyright (c) 2004 by Fritz Keinert (keinert@iastate.edu),
% Dept. of Mathematics, Iowa State University, Ames, IA 50011.
% This software may be freely used and distributed for non-commercial
% purposes, provided this copyright statement is preserved, and
% appropriate credit for its use is given.
%
% Last update: Feb 20, 2004
format compact;
disp(' ');
disp('## This Matlab script file illustrates the use of the mpoly toolbox.');
disp('## A description of each step, and the command used to produced it,');
disp('## are shown AFTER each step. Scroll back to see the output.');
disp(' ');
dummy = input('hit <return> to continue');
disp(' ');
P = mpoly({[1,2;3,4],[5,6;7,8]})
disp(' ');
disp('## Create a matrix polynomial');
disp('## P = mpoly({[1,2;3,4],[5,6;7,8]})');
disp(' ');
dummy = input('Hit <return> to continue');
disp(' ');
z = mpoly(1,1)
disp(' ');
U = [1,1;1,-1]/sqrt(2)
disp(' ');
I = eye(2)
disp(' ');
Q = (I-U) + U*z
disp(' ');
disp('## Create another one');
disp('## z = mpoly(1,1)');
disp('## U = [1,1;1,-1]/sqrt(2)');
disp('## I = eye(2)');
disp('## Q = (I-Q) + Q*z');
disp(' ');
dummy = input('Hit <return> to continue');
disp(' ');
R = P*Q
disp(' ');
disp('## Multiply them');
disp('## R = P*Q');
disp(' ');
dummy = input('hit <return> to continue');
disp(' ');
P2 = R/Q
disp(' ');
disp('## Divide again');
disp('## P2 = R/Q');
disp(' ');
dummy = input('hit <return> to continue');
disp(' ');
P == P2
disp(' ');
disp('## Check result (1 = true, 0 = false)');
disp('## P == P2');
disp(' ');
dummy = input('hit <return> to continue');
disp(' ');
P = sym(P)
disp(' ');
U = sym(U)
disp(' ');
Q = (I-U) + U*z
disp(' ');
disp('## Convert P, Q to symbolic form');
disp('## P = sym(P)');
disp('## Q = sym(Q)');
disp(' ');
dummy = input('hit <return> to continue');
disp(' ');
R = P*Q
disp(' ');
P2 = R/Q
disp(' ');
P == P2
disp(' ');
disp('## Do same calculations again, this time in symbolic form');
disp('## R = P*Q');
disp('## P2 = R/Q');
disp('## P == P2');
disp(' ');
dummy = input('hit <return> to continue');
disp(' ');
Z = zeros(2)
disp(' ');
B = [P,Z;Z,-P]
disp(' ');
disp('## Build a bigger matrix from pieces');
disp('## Z = zeros(2)');
disp('## B = [P,Z;Z,-P]');
disp(' ');
dummy = input('hit <return> to continue');
disp(' ');
D = diag(P)
disp(' ');
disp('## Extract the diagonal');
disp('## D = diag(P)');
disp(' ');
dummy = input('hit <return> to continue');
disp(' ');
Pstar = P'
disp(' ');
disp('## Compute the complex conjugate transpose');
disp('## Pstar = P''');
disp(' ');
dummy = input('hit <return> to continue');
disp(' ');
Pt = P.'
disp(' ');
disp('## Compute the real transpose');
disp('## Pt = P''');
disp(' ');
dummy = input('hit <return> to continue');
disp(' ');
row = P(1,:)
disp(' ');
disp('## Extract the first row');
disp('## row = P(:,1)');
disp(' ');
dummy = input('hit <return> to continue');
disp(' ');
P1 = P{1}
disp(' ');
disp('## Extract the coefficient of z^1');
disp('## P1 = P{1}');
disp(' ');
dummy = input('hit <return> to continue');
disp(' ');
P2 = P{2}
disp(' ');
disp('## Extract the coefficient of z^2');
disp('## P2 = P{2}');
disp(' ');
dummy = input('hit <return> to continue');
disp(' ');
P{3} = I
disp(' ');
disp('## Add a coefficient');
disp('## P{3} = I');
disp(' ');
dummy = input('hit <return> to continue');
disp(' ');
P.max
disp(' ');
disp('## Find the largest power in P');
disp('## P.max');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -