求指点MATLAB的save函数?

如下,从第四行开始是什么意思,菜鸟太菜。。
>> A=ones(2,3);
>> B=[1,2,3];
>> C=magic(5);
>> save mydate A
>> save('mydate','B','-append');
>> save('mydate','C','-ascii')

白板的微信
浏览 1664回答 3
3回答

jeck猫

MATLAB储存变数的基本命令是save,在不加任何选项(Options)时,save会将变数以二进制(Binary)的方式储存至副档名为mat的档案,如下述:save:将工作空间的所有变数储存到名为matlab.mat的二进制档案。save filename:将工作空间的所有变数储存到名为filename.mat的二进制档案。 save filename x y z :将变数x、y、z储存到名为filename.mat的二进制档案。以下为使用save命令的一个简例:who % 列出工作空间的变数Your variables are:B h j yans i x zsave test B y % 将变数B与y储存至test.matdir % 列出现在目录中的档案. 2plotxy.doc fact.m simulink.doc test.m ~$1basic.doc.. 3plotxyz.doc first.doc temp.doc test.mat1basic.doc book.dot go.m template.doc testfile.datdelete test.mat % 删除test.mat以二进制的方式储存变数,通常档案会比较小,而且在载入时速度较快,但是就无法用普通的文书软体(例如pe2或记事本)看到档案内容。若想看到档案内容,则必须加上-ascii选项,详见下述:save filename x -ascii:将变数x以八位数存到名为filename的ASCII档案。Save filename x -ascii -double:将变数x以十六位数存到名为filename的ASCII档案。另一个选项是-tab,可将同一列相邻的数目以定位键(Tab)隔开。小提示:二进制和ASCII档案的比较 在save命令使用-ascii选项後,会有下列现象:save命令就不会在档案名称後加上mat的副档名。因此以副档名mat结尾的档案通常是MATLAB的二进位资料档。若非有特殊需要,我们应该尽量以二进制方式储存资料。

慕标5832272

>> save mydate A把变量A存为 mydate.mat 文件>> save('mydate','B','-append');把变量B添加到 mydate.mat 文件中,现在 mydate.mat有两个变量A和B>> save('mydate','C','-ascii')把变量C以ASCII格式存为mydate 文件

慕桂英3389331

  save函数  保存当前工作空间的所有变量到文件名制定的文件中,此文件后缀名通常为mat。如果不指定文件名变量,则会默认保存到matlab.mat这个文件中的一种运算符法。  函数编程:  SAVE Save workspace variables to disk.  SAVE FILENAME saves all workspace variables to the binary "MAT-file"  named FILENAME.mat. The data may be retrieved with LOAD. If FILENAME  has no extension, .mat is assumed.  SAVE, by itself, creates the binary "MAT-file" named 'matlab.mat'.  SAVE FILENAME X saves only X.  SAVE FILENAME X Y Z saves X, Y, and Z. The wildcard '*' can be used to  save only those variables that match a pattern.  SAVE FILENAME -REGEXP PAT1 PAT2 can be used to save all variables  matching the specified patterns using regular expressions. For more  information on using regular expressions, type "doc regexp" at the  command prompt.  SAVE FILENAME -STRUCT S saves the fields of the scalar structure S as  individual variables within the file FILENAME.  SAVE FILENAME -STRUCT S X Y Z saves the fields S.X, S.Y and S.Z to  FILENAME as individual variables X, Y and Z.  SAVE FILENAME ... -APPEND adds the variables to an existing file  (MAT-file only).  Format Options:  SAVE ... -ASCII uses 8-digit ASCII form instead of binary regardless  of file extension.  SAVE ... -ASCII -DOUBLE uses 16-digit ASCII form.  SAVE ... -ASCII -TABS delimits with tabs.  SAVE ... -ASCII -DOUBLE -TABS 16-digit, tab delimited.  SAVE ... -MAT saves in MAT format regardless of extension.  Version Compatibility Options:  The following options enable you to save your workspace data to a  MAT-file that can then be loaded into an earlier version of MATLAB.  The resulting MAT-file supports only those data items and features  that were available in this earlier version of MATLAB. (See the  second table below for what is supported in each version.)  Command Option | Saves a MAT-File That You Can Load In  主要公式:  -----------------+----------------------------------------------  SAVE ... -V7.3 | Version 7.3 or later  -----------------+----------------------------------------------  SAVE ... -V7 | Versions 7.0 through 7.2 (or later)  -----------------+----------------------------------------------  SAVE ... -V6 | Versions 5 and 6 (or later)  -----------------+----------------------------------------------  SAVE ... -V4 | Versions 1 through 4 (or later)  To make one of these options the default for all of your MATLAB  sessions, use the Preferences dialog box. In the MATLAB File menu,  select Preferences. Then, in the Preferences dialog box, click  General and then MAT-Files.  MATLAB Versions | Data Items or Features Supported  -----------------+----------------------------------------------  4 and earlier | Support for 2D double, character, and sparse  | arrays  -----------------+----------------------------------------------  5 and 6 | Version 4 capability plus support for  | ND arrays, structs, and cells  -----------------+----------------------------------------------  7.0 through 7.2 | Version 6 capability plus support for data  | compression and Unicode character encoding  -----------------+----------------------------------------------  7.3 and later | Version 7.2 capability plus support for  | data items greater than or equal to 2GB  Examples for pattern matching:  save fname a* % Save variables starting with "a"  save fname -regexp \d % Save variables containing any digits  Examples for specifying filename and variables:  save mydata.mat v1 % Use with literal filename  save 'my data file.mat' v1 % Use when filename has spaces  save(savefile, 'v1') % Use when filename is stored in a variable
打开App,查看更多内容
随时随地看视频慕课网APP