关键词不能为空

当前您在: 主页 > 英语 >

矩阵语言简介

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-02-28 08:51
tags:

-

2021年2月28日发(作者:频率计)



矩阵语言简介



在已 经建立的工作文件中,可以通过菜单或者命令建立矩阵对象。



菜单方式:



命令方式:




Eviews


提供了可以直接对矩阵和向量中的数据进行操作的矩阵语言。使用矩阵语 言可以完成许



Eviews


内置的菜 单命令中没有的操作。使用矩阵语言可以创建和操作下列对象:



Matrix:


二维数组









Sym:


对称矩阵




Vector:


列向量





Rowvector:


行向量




Scalar:


标量







常用的函数:


@transpose,


转置





@det,


求行列式



@eigenvalues,


求特征值




@eigenvectors,


求特 征向量





@inner


,求内积





@inverse ,


求逆矩阵



@rank


,求秩




行列式:


matrix



4



4

< br>)



x



scalar xdet



@det(x)



矩阵求逆:


matrix


< br>4



4




x



matrix xinv



@inverse(x)



矩阵求迹:


matrix


< p>
4



4




x



scalar xinv



@trace(x)



矩阵求秩:


scalar rank1 = @rank(m1)


矩阵求特征根与特征向量:


matrix



4



4




x



vector v1 = @eigenvalues(x)




matrix m2 = @eigenvectors(x)




矩阵加减:


matrix(6,4) xdata



6



matrix(6,4) ydata



4



matrix(6,4)



zdata



xdata


ydata



矩阵乘法




内积:



vector



8




x1



2



vector



8



x2



3



scalar y



@transpose(x1)*x2



如果已经定义好了矩阵,不妨设为


A



B


,那么可以定义矩阵的乘积为



Matrix



C=A*B


在命令窗口中输入上述命令即可,在工作文件中就 是矩阵


C




二次形:


scalar z = vec1*@inverse(matrix)*@transpose(vec1)




建立一个对称矩阵:


sym, s1


进行乔里斯基分解(


Cholesky decomposition


):


matrix fact = @cholesky(s1)




然后验证:


matrix orig = fact*@transpose(fact)




1.


声明矩阵对象



例子:


matrix(3,10)



xdata


:创建一个


3


×


10


矩阵


xdata




Sym(9)



moments


:创建一个


9


×


9


的对称矩阵


moments




Vector(11)



betas


:创建一个


11


×

1


的列向量


betas




Rowvector(5) xob


:创建一 个


1


×


5


的行 向量


xob




要改变矩阵对象的维数,


只需再声明一次。


此外,

< p>
如果使用赋值语句把已存在的矩阵对象赋给另


一个矩阵对象,则目标对象的 维数将会做相应的调整。例如



Sym(10) bigz


:创建一个


10


×


10


的对称矩阵


bigz


< p>


Matrix zdata


:创建矩阵


zdata


,它只有一个元素。



Matrix(10,2) zdata


:把

< br>zdata


重新声明成


10


×< /p>


2.


Zdata=bigz


:矩阵


zdata


被调整成


10

< br>×


10


的矩阵,和


bigz


的内容一样。



给矩阵对象赋值



有三种赋值方式。



第一种。声明一个


2


×


2


的矩阵 :


Matrix



2,2




a


。其中矩阵



a


的所有元素都是


0.


执行下面


的命令:



a(1,1)=1


a(2,1)=4


?


1



0


?


就得到


a=


?


?


.


4



0


?


?


第二种 。用


fill


据表赋给矩阵。使用


fi ll


语句时,用矩阵对象名加“


.


”< /p>


,然后加


fill


,后面跟


以逗号分隔的数据表。例如



Vector(3) v


V


.fill 0.1,0.2,0.3


Matrix(2,4) x


1,2,3,4,5,6,7,8


上面的命令创建了




?


0


.


1


?


?


x


?


?


1



3



5



7



?



v


?


?


0


.


2


?


2



4



6



8


?


?


?


?


?


?


?


0


.


3


?


?


如果把上面最后 一行命令换为:


(b=r) 1,2,3,4,5,6,7,8


则得到



?


1



2



3



4


?


x


?


?


?


?


5



6



7



8


?



有时候 希望把数据表重复赋值给矩阵对象。这时候可以用“


1


”选项。 例如



Matrix(3,3) y


(1) 1,0,-1


就会创建



?


1



1



1


?


?



y


?


?


0



0



0


?


?


?


?< /p>


-


1



-


1



-< /p>


1


?


?


第三种。 矩阵赋值语句。



使用矩阵赋值语句可以把一个矩阵对象的数据 复制到另一个矩阵对象里。


赋值语句以等号连


接源对象和目标对 象,


等号右边必须是常数值矩阵对象或者返回值为矩阵对象的表达式。

< br>如果等


号右边是标量,则等式左边的矩阵对象的所有元素都会被赋以这个标量的值 。例如:



Matrix(5,8)first


First=5


矩阵


First


的所有元素都被赋为


5.


可以把声明和赋 值语句结合起来,在声明矩阵对象的同时进行初始化。例如:



Matrix(5,8)



first=5



创建


5


×


8


的矩阵


first


,所有元素都为


5.


Vector(10)



v= first(3,5)


创建向量


v


, 所有元素都等于矩阵


first


的第


3


行第


5


列的元素。


如果赋值对象和目标对象属于同一类型,则目标对象的维数会被调整成和源对象的 一样。例如:



Matrix(10,2)



zdata=5



创建


10


×


2


的矩阵


zdata


,每个元素的值都是


5


Matrix



ydata=zdata




创建矩阵


ydata


,维数和


zdata


的一样,为


10


×


2


Matrix(10,10)



xdata=ydata




尽管声明


xdata



10


×


10


的矩阵,但是这行执行后 ,


xdata



10


×


2


的矩阵,每个元素都是< /p>


5.



3



1


从矩阵中提取向量或子块





matrix(10, 10) m1



vector v1 = @vec(m1)



vector v2 = @columnextract(m1,3)



vector v3 = @rowextract(m1,4)



vector v4 = @columnextract(sym1,5)



The @vec function creates a 100 element vector, V1, from the columns of M1 stacked one on


top of another. V2 will be a 10 element vector containing the contents of the third column of M1


while V3 will be a 10 el ement vector containing the fourth row of M1. The @vec, @rowextract,


and


@columnextract


functions


also


work


with


sym


objects.


V4


is


a


10


element


vector


containing the fifth column of SYM1.


You can also copy data from one matrix into a smaller matrix using



@subextract. For example:



matrix(20,20) m1=1



matrix m2 = @subextract(m1,5,5,10,7)



matrix m3 = @subextract(m1,5,10)



matrix m4 = m1



M2


is


a



matrix


containing


a


submatrix


of


M1


defined


by


taking


the


part


of


the


matrix


M1


beginning at row 5 and column 5 and ending at row 10 and column 7. M3 is the



matrix taken


from M1 at row 5 and column 1 0 to the last element of the matrix (ro


w 20 and column 20). In


contrast, M4 is defined to be an exact copy of the full



matrix.




3



2


从时间序列中生成矩阵




smpl 1963:3 1993:6



group mygrp hsf gmpyq



vector xvec = gmpyq



matrix xmat = mygrp



These statements create the vector XVEC and the two column matrix XMAT containing the


non-missing series and group data from 1963:3 to 1993:6. Note that if GMPYQ has a missing


value in 1970:01, and HSF contains a missing value in 1980:01, both observations for both


series will be excluded from XMAT.


Matrix


帮助



Matrix (two-dimensional array).




Matrix Declaration



matrix


declare matrix object.



There are several ways to create a matrix object. You can enter the matrix keyword (with an


optional row and column dimension) followed by a name:



matrix scalarmat



matrix(10,3) results



Alternatively, you can combine a declaration with an assignment statement, in which case the


new matrix will be sized accordingly.



Lastly, a number of object procedures create matrices.



Matrix Views



cor


correlation matrix by columns.



cov


covariance matrix by columns.



display


display table, graph, or spool in object window .



label


label information for the matrix.



pcomp


principal components analysis of the columns in a matrix.



sheet


spreadsheet view of the matrix.



stats


descriptive statistics by column.



Matrix Graph Views



Graph creation views are discussed in detail in



.



area


area graph of the columns in the matrix.



band


area band graph.



bar


bar graph of each column.



boxplot


boxplot of each column.



distplot


distribution graph .



dot


dot plot graph .



errbar


error bar graph view.



hilo


high-low(-open-close) chart.



line


line graph of each column.



pie


pie chart view.




qqplot


quantile-quantile graph.



scat


scatter diagrams of the columns of the matrix.



scatmat


matrix of all pairwise scatter plots.



scatpair


scatterplot pairs graph.



seasplot


seasonal line graphof the columns of the matrix.



spike


spike graph.



xyarea


XY area graph.



xybar


XY bar graph.



xyline


XY line graph.



xypair


XY pairs graph.



Matrix Procs



displayname


set display name.



fill


fill the elements of the matrix.



read


import data from disk.



setformat


set the display format for the matrix spreadsheet.



setindent


set the indentation for the matrix spreadsheet.



setjust


set the justification for the matrix spreadsheet.



setwidth


set the column width in the matrix spreadsheet.



write


export data to disk.



Matrix Data Members



String values



@description string containing the Matrix object's description (if available).



@detailedtype string with the object type:



@displayname string containing the Matrix object's display name. If the Matrix has no display


name set, the name is returned.



@name string containing the Matrix object's name.



@remarks string containing the Matrix object's remarks (if available).



@source string containing the Matrix object's source (if available).



@type string with the object type:




@units string containing the Matrix object's units description (if available).



@updatetime string representation of the time and date at which the Matrix was last updated.



Scalar values



(i,j) (


i


,

< br>j


)-th element of the matrix. Simply append


i


,


j


)



Matrix Examples



The following assignment statements create and initialize matrix objects,



matrix copymat=results



matrix covmat1=eq1.@coefcov



matrix(5,2) count



1,2,3,4,5,6,7,8,9,10



as does the equation procedure:



efcov covmat2



You can declare and initialize a matrix in one command:



matrix(10,30) results=3



matrix(5,5) other=results1



Graphs and covariances may be generated for the columns of the matrix,







and statistics computed for the rows of a matrix:



matrix rowmat=@transpose(copymat)





You can use explicit indices to refer to matrix elements:



scalar diagsum=cov1(1,1)+cov1(2,2)+cov(3,3)



Matrix Language Reference


The following entries constitute a listing of the functions and commands used in the EViews


matrix language. For a description of the EViews matrix language, see



.



Matrix Command and Function Summary


Matrix Utility Commands


colplace


Places column vector into matrix.



matplace


Places matrix object in another matrix object.


-


-


-


-


-


-


-


-



本文更新与2021-02-28 08:51,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/680008.html

矩阵语言简介的相关文章