📄 mata_matsave.hlp
字号:
{smcl}
{* 07apr2005}{...}
{cmd:help mata matsave}
{hline}
{* index mata tt}{...}
{* index matsave tt}{...}
{* index matuse tt}{...}
{* index matdescribe tt}{...}
{* index .mmat files}{...}
{title:Title}
{p 4 4 2}
{bf:[M-3] mata matsave -- Save and restore matrices}
{title:Syntax}
{p 8 16 2}
: {cmd:mata} {cmd:matsave}
{it:filename}
{it:namelist}
[{cmd:,}
{cmd:replace}
]
{p 8 16 2}
: {cmd:mata} {cmd:matuse}
{it:filename}
[{cmd:,}
{cmd:replace}
]
{p 8 16 2}
: {cmd:mata} {cmdab:matd:escribe}
{it:filename}
{p 4 4 2}
where {it:namelist} is a list of matrix names as defined in
{bf:{help m3_namelists:[M-3] namelists}}.
{p 4 4 2}
If {it:filename} is specified without a suffix, {cmd:.mmat} is assumed.
{p 4 4 2}
These commands are for use in Mata mode following Mata's colon prompt.
To use these commands from Stata's dot prompt, type
. {cmd:mata: mata matsave} ...
{title:Description}
{p 4 4 2}
{cmd:mata} {cmd:matsave} saves the specified global matrices in
{it:filename}.
{p 4 4 2}
{cmd:mata} {cmd:matuse} loads the matrices stored in {it:filename}.
{p 4 4 2}
{cmd:mata} {cmd:matdescribe} describes the contents of {it:filename}.
{title:Option for mata matsave}
{p 4 8 2}
{cmd:replace} specifies that {it:filename} may be replaced if it already exists.
{title:Option for mata matuse}
{p 4 8 2}
{cmd:replace} specifies that any matrices in memory with the same name as
those stored in {it:filename} can be replaced.
{title:Remarks}
{p 4 4 2}
These commands are for interactive use; they are not for use
inside programs. See {bf:{help mf_fopen:[M-5] fopen()}} for Mata's
programming functions for reading and writing files.
In the programming environment,
if you have a matrix {it:X} and want to write it to file
mymatrix.myfile, you code
{cmd}fh = fopen("mymatrix.myfile", "w")
fputmatrix(fh, X)
fclose(fh){txt}
{p 4 4 2}
Later, you can read it back by coding
{cmd}fh = fopen("mymatrix.myfile", "r")
fgetmatrix(fh, X)
fclose(fh){txt}
{p 4 4 2}
{cmd:mata} {cmd:matsave},
{cmd:mata} {cmd:matuse},
and
{cmd:mata} {cmd:matdescribe}
are for use outside of programs, when you are working interactively.
You can save your global matrices
: {cmd:mata matsave mywork *}
(saving A, X, Z, beta)
file mywork.mmat saved
{p 4 4 2}
and then later get them back
: {cmd:mata matuse mywork}
(loading A, X, Z, beta)
{p 4 4 2}
{cmd:mata} {cmd:matdescribe} will tell you the contents of a file
: {cmd:mata matdescribe mywork}
file mywork.mmat saved on 4 Apr 2005 08:46:39 contains
X, X, Z, beta
{title:Diagnostics}
{p 4 4 2}
{cmd:mata} {cmd:matsave} saves the contents of view matrices. Thus
when they are restored by {cmd:mata} {cmd:matuse}, the contents will be
correct regardless of the data Stata has loaded in memory.
{title:Source code}
{p 4 4 2}
{view mata_matsave.ado, adopath asis:mata_matsave.ado},
{view mata_matuse.ado, adopath asis:mata_matuse.ado},
{view mata_matdescribe.ado, adopath asis:mata_matdescribe.ado},
{view mmat_.mata, adopath asis:mmat_.mata}
{title:Also see}
{p 4 13 2}
Manual: {hi:[M-3] mata matsave}
{p 4 13 2}
Online: help for
{bf:{help m3_intro:[M-3] intro}}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -