Save file matlab

Save file matlab DEFAULT

Select a Web Site

Save and Load Workspace Variables

The workspace is not maintained across sessions of MATLAB®. When you quit MATLAB, the workspace clears. However, you can save any or all the variables in the current workspace to a MAT-file (). You can then reuse the workspace variables later during the current MATLAB session or during another session by loading the saved MAT-file.

Save Workspace Variables

There are several ways to save workspace variables interactively:

  • To save all workspace variables to a MAT-file, on the Home tab, in the Variable section, click Save Workspace.

  • To save a subset of your workspace variables to a MAT-file, select the variables in the Workspace browser, right-click, and then select . You also can drag the selected variables from the Workspace browser to the Current Folder browser.

  • To save variables to a MATLAB script, click the Save Workspace button or select the option, and in the Save As window, set the Save as type option to . Variables that cannot be saved to a script are saved to a MAT-file with the same name as that of the script.

You also can save workspace variables programmatically using the function. For example, to save all current workspace variables to the file , use the command

To save only variables and to the file , use the command

To store fields of a scalar structure as individual variables, use the function with the option. This can be useful if you previously loaded variables from a MAT-File into a structure using the syntax and want to keep the original variable structure when saving to a new MAT-File.

To save part of a variable, use the function. This can be useful if you are working with very large data sets that are otherwise too large to fit in memory. For more information, see Save and Load Parts of Variables in MAT-Files.

In MATLAB Online&#x;, variables persist between sessions. Saving allows you to clear the workspace and load variables at a later time. To save variables, use the or functions.

Load Workspace Variables

To load saved variables from a MAT-file into your workspace, double-click the MAT-file in the Current Folder browser.

To load a subset of variables from a MAT-file on the Home tab, in the Variable section, click Import Data. Select the MAT-file you want to load and click Open. You also can drag the desired variables from the Current Folder browser Details panel of the selected MAT-file to the Workspace browser. The Details panel is not available in MATLAB Online.

To load variables saved to a MATLAB script into the workspace, simply run the script.

You also can load saved variables programmatically, use the function. For example, load all variables from the file

To load variables and from the file

To load part of a variable, use the function. This is useful if you are working with very large data sets that are otherwise too large to fit in memory. For more information, see Save and Load Parts of Variables in MAT-Files.

Caution

When you load data into the MATLAB workspace, the new variables you create overwrite any existing variables in the workspace that have the same name. To avoid overwriting existing variables, use the function to load the variables into a structure. For example, loads all the variables from the file into the structure .

View Contents of MAT-File

To see the variables in a MAT-file before loading the file into your workspace, click the file name in the Current Folder browser. Information about the variables appears in the Details pane.

Alternatively, use the command . This function returns the name, dimensions, size, and class of all variables in the specified MAT-file. For example, you can view the contents of the example file .

Name Size Bytes Class Attributes X x double caption 2x28 char map x3 double

The byte counts represent the number of bytes that the data occupies in memory when loaded into the MATLAB workspace. Because of compression, data encoding, and metadata, the space occupied in the file by a variable may be different from the in-memory size. MATLAB compresses data in Version 7 or higher MAT-files. For more information, see MAT-File Versions.

See Also

|

Related Topics

Sours: https://www.mathworks.com/help/matlab/matlab_env/save-load-and-delete-workspace-variables.html
MATLAB Function Reference   
save

Save workspace variables on disk

Graphical Interface

As an alternative to the function, select Save Workspace As from the File menu in the MATLAB desktop, or use the Workspace browser.

Syntax

  • save save filename save filename var1 var2 save('filename', )

Description

by itself, stores all workspace variables in a binary format in the current directory in a file named . Retrieve the data with . MAT-files are double-precision, binary, MATLAB format files. They can be created on one machine and later read by MATLAB on another machine with a different floating-point format, retaining as much accuracy and range as the different formats allow. They can also be manipulated by other programs external to MATLAB.

stores all workspace variables in the current directory in . To save to another directory, use the full pathname for the . If is the special string , the command sends the data as standard output.

saves only the specified workspace variables in . Use the wildcard to save only those variables that match the specified pattern. For example, saves all variables that start with .

saves the workspace variables in the format specified by

option Argument
Result: How Data is Stored

The specified existed MAT-file, appended to the end

8-digit ASCII format

digit ASCII format

delimits with tabs

digit ASCII format, tab delimited

Binary MAT-file form (default)

A format that MATLAB version 4 can open

Remarks

When saving in ASCII format, consider the following:

  • Each variable to be saved must be either a two dimensional double array or a two dimensional character array. Saving a complex double array causes the imaginary part of the data to be lost, as MATLAB cannot load nonnumeric data ().
  • In order to be able to read the file with the MATLAB function, all of the variables must have the same number of columns. If you are using a program other than MATLAB to read the saved data this restriction can be relaxed.
  • Each MATLAB character in a character array is converted to a floating point number equal to its internal ASCII code and written out as a floating point number string. There is no information in the save file that indicates whether the value was originally a number or a character.
  • The values of all variables saved merge into a single variable that takes the name of the ASCII file (minus any extension). Therefore, it is advisable to save only one variable at a time.

With the flag, you can only save data constructs that are compatible with versions of MATLAB 4. Therefore, you cannot save structures, cell arrays, multidimensional arrays, or objects. In addition, you must use filenames that are supported by MATLAB version 4.

is the function form of the syntax.

For more control over the format of the file, MATLAB provides other functions, as listed in See Also, below.

Algorithm

The binary formats used by depend on the size and type of each array. Arrays with any noninteger entries and arrays with 10, or fewer elements are saved in floating-point formats requiring 8 bytes per real element. Arrays with all integer entries and more than 10, elements are saved in the formats shown, requiring fewer bytes per element.

Element Range
Bytes per Element
0 to
1
0 to
2
to
2
-231+1 to 231-1
4
other
8

External Interfaces to MATLAB provides details on reading and writing MAT-files from external C or Fortran programs. It is important to use recommended access methods, rather than rely upon the specific MAT-file format, which is likely to change in the future.

Examples

To save all variables from the workspace in binary MAT-file, , type

To save variables and in binary MAT-file, , type

  • savefile = 'test.mat'; p = rand(1,10); q = ones(10); save(savefile,'p','q')

To save the variables and in ASCII format to a file named , type

  • save('d:\mymfiles\june10','vol','temp','-ASCII')

See Also
, , , ,

  runtime saveas 

Sours: http://www.ece.northwestern.edu/local-apps/matlabhelp/techdoc/ref/save.html
  1. Kevin bronson wife
  2. Biltmore estate jobs salary
  3. Db link lighting solutions
  4. Columbia police department missouri

Select a Web Site

Save and Back Up Code

You can save your files in the Editor and Live Editor using several methods. In the Editor, you also can create backup copies of your files. Creating backup copies of your files ensures that you have a known working version of the files before making changes to them, and can also be useful for recovering lost changes after a system problem.

Depending on your needs, you can also control how the files you save are encoded and cached.

Save Code

When you modify a file in the Editor or the Live Editor, MATLAB® indicates that there are unsaved changes in the file by displaying an asterisk (*) next to the file name in the document tab.

To save the file, go to the Editor or Live Editor tab, and in the File section, click Save.

To change the name, location, or type of a file, select > . For example, to save a live script as a plain code file (), on the Live Editor tab, in the File section, select > . In the dialog box that appears, select as the Save as type and click Save.

Back Up Code

You can create backup copies of your files in the Editor. Creating a backup copy of a file ensures that you have a known working version of the file before making changes to it. To create a backup copy of a file, on the Editor tab, in the File section, select > . This option is not available in the Live Editor or in MATLAB Online&#x;.

In addition, when you modify files in the Editor, MATLAB automatically creates backup copies of the files. If you lose changes to your files due to system problems, you can use the automatically created backup copies of the files to recover the changes.

By default, MATLAB saves a backup copy of a modified file every five minutes using the same file name but with an extension. For example, would have a backup file name of . If you lose changes to your file, you can recover the unsaved changes by opening the backup copy of the file, , and saving it as .

To change how and when MATLAB saves backup copies of files, on the Home tab, in the Environment section, click Preferences. Then, select > > . You can specify:

  • How often to save backup copies of the files you are editing.

  • What file extension to use when creating backup copies of files.

  • Where to save backup copies of files.

  • Whether to automatically delete backup copies of files when you close the corresponding source file in the Editor.

For more information about the available options, see the Backup Files preferences in Editor/Debugger Preferences.

In MATLAB Online, every time you save a code file in the Editor, MATLAB stores the contents of your code file in the version history. For more information about recovering a previous version of a file in MATLAB Online, see Restore Files in MATLAB Online.

MATLAB does not automatically create backups of files modified in the Live Editor.

Recommendations on Saving Files

MathWorks® recommends that you save files that you create to a folder outside the folder tree, where is the folder returned when you type in the Command Window. Similarly, when you edit files that you get from MathWorks, save your edited version outside the folder tree. If you save your files in the folder tree, they can be overwritten when you install a new version of MATLAB.

If you do save files in the folder tree, you may need to take extra steps for your changes to take effect. At the beginning of each MATLAB session, MATLAB loads and caches in memory the locations of files in the folder tree. Therefore, if you add, remove, or make changes to files in the folder tree using an external editor or file system operations, you must update the cache so that MATLAB recognizes the changes you made. For more information, see Toolbox Path Caching in MATLAB.

File Encoding

As of Ra, when the Editor saves a new MATLAB code file that has a extension, such as a script or a function, it uses UTF-8 without a byte-order-mark (BOM). The Editor saves existing files with their current encoding unless a different one is selected from the Save As dialog. For example, to save a file using a legacy locale-specific encoding for compatibility with an earlier release of MATLAB, on the Editor tab, in the File section, select > . In the dialog box that appears, select the desired encoding from the Save as type options.

The current encoding is displayed next to the file name in the Editor status bar or, if the Editor Window is docked, the Desktop status bar.

Related Topics

Sours: https://www.mathworks.com/help/matlab/matlab_prog/save-and-back-up-code.html

save

Main Content

Syntax

Description

example

saves all variables from the current workspace in a MATLAB® formatted binary file (MAT-file) called . If exists, overwrites the file.

example

saves in the file format specified by . The argument is optional. If you do not specify , the function saves all variables in the workspace.

example

saves the variables to the MAT-file without compression. The flag only supports MAT-file Version 7 (default) and Version Therefore, you must specify as or . The argument is optional.

example

adds new variables to an existing file. If a variable already exists in a MAT-file, then overwrites it with the value in the workspace.

For ASCII files, adds data to the end of the file.

To append to a Version 6 MAT-file, you must also include as an input argument.

example

adds new variables to an existing file without compression. The existing file must be a MAT-file Version 7 (default) or

example

is the command form of the syntax. Command form requires fewer special characters. You do not need to type parentheses or enclose the input in single or double quotes. Separate inputs with spaces instead of commas.

For example, to save a file named , these statements are equivalent:

save test.mat % command form save('test.mat') % function form

You can include any of the inputs described in previous syntaxes. For example, to save the variable named :

save test.mat X % command form save('test.mat','X') % function form

Do not use command form when any of the inputs, such as , are variables or strings.

Examples

collapse all

Save All Workspace Variables to MAT-File

Save all variables from the workspace in a binary MAT-file, . If is a variable, use function syntax.

filename = 'test.mat'; save(filename)

Otherwise, you also can use command syntax.

Remove the variables from the workspace, and then retrieve the data with the function.

Save Specific Variables to MAT-File

Create and save two variables, and , to a file called .

p = rand(1,10); q = ones(10); save('pqfile.mat','p','q')

MATLAB&#; saves the variables to the file, , in the current folder.

You also can use command syntax to save the variables, and .

Save Data to ASCII File

Create two variables, save them to an ASCII file, and then view the contents of the file.

p = rand(1,10); q = ones(10); save('pqfile.txt','p','q','-ascii') type('pqfile.txt')

The function displays the contents of the file.

Alternatively, use command syntax for the operation.

save pqfile.txtpq-ascii

Save Structure Fields as Individual Variables

Create a structure, , that contains three fields, , , and .

s1.a = ; s1.b = {'abc',[4 5; 6 7]}; s1.c = 'Hello!';

Save the fields of structure as individual variables in a file called .

save('newstruct.mat','-struct','s1');

Check the contents of the file using the function.

disp('Contents of newstruct.mat:')
Contents of newstruct.mat:
whos('-file','newstruct.mat')
Name Size Bytes Class Attributes a 1x1 8 double b 1x2 cell c 1x6 12 char

Save Variables to Version MAT-File

Create two variables and save them to a Version MAT-file called .

A = rand(5); B = magic(10); save('example.mat','A','B','-v')

You also can use command syntax for the operation.

save example.matAB-v

Save Variables to MAT-File Without Compression

Create two variables and save them, without compression, to a Version or MAT-file called .

A = rand(5); B = magic(10); save('myFile.mat','A','B','-v','-nocompression')

Alternatively, use the command syntax for the operation.

save myFile.matAB-vnocompression

The flag facilitates a faster save for those variables that are larger than GB or those that do not benefit from compression.

Append Variable to MAT-File

Save two variables to a MAT-file. Then, append a third variable to the same file.

p = rand(1,10); q = ones(10); save('test.mat','p','q')

View the contents of the MAT-file.

Name Size Bytes Class Attributes p 1x10 80 double q 10x10 double

Create a new variable, , and append it to the MAT-file.

a = 50; save('test.mat','a','-append')

View the contents of the MAT-file.

Name Size Bytes Class Attributes a 1x1 8 double p 1x10 80 double q 10x10 double

The variable, , is appended to , without overwriting the previous variables, and .

Note

To append to a Version 6 MAT-file, specify both and . For example, to save variable to the file, , call:

save('test.mat','a','-v6','-append')

Append Variable to MAT-File Without Compression

Save two variables to a MAT-file. Then, append a third variable, without compression, to the same file.

Create two variables and and save them to a MAT-file Version or . By default, the function compresses variables and before saving them to .

A = rand(5); B = magic(10); save('myFile.mat','A','B','-v')

View the contents of the MAT-file.

whos('-file','myFile.mat')
Name Size Bytes Class Attributes A 5x5 double B 10x10 double

Create a new variable and append it, without compression, to .

C = 5; save('myFile.mat','C','-append','-nocompression')

View the contents of the MAT-file.

whos('-file','myFile.mat')
Name Size Bytes Class Attributes A 5x5 double B 10x10 double C 1x1 8 double

Input Arguments

collapse all

&#; Name of file
(default) | character vector | string scalar

Name of file, specified as a character vector or string scalar. If you do not specify , the function saves to a file named .

If has no extension (that is, no period followed by text), and the value of is not specified, then MATLAB appends . If does not include a full path, MATLAB saves to the current folder. You must have permission to write to the file.

When using the command form of , you do not need to enclose the input in single quotes. However, if contains a space, you must enclose the argument in single quotes. For example, .

Note

Do not use command form when is a string.

To save workspace variables to a MAT-file in a remote location, specify as a uniform resource locator (URL) of this form:

Based on your remote location, can be one of the values in this table.

Remote Location
Amazon S3&#x;
Windows Azure® Blob Storage,

The function only supports saving version MAT-files to remote locations.

For more information on setting up MATLAB to access your online storage service, see Work with Remote Data.

Example:

Example:

&#; Names of variables to save
character vector | string scalar

Names of variables to save, specified as character vectors or string scalars. When using the command form of , you do not need to enclose the input in single quotes.

Note

Do not use command form when is a string.

can be in one of the following forms.

Form of InputVariables to Save
Save the listed variables, specified as individual character vectors or strings.
Use the wildcard to match patterns. For example, saves all variables in the file that start with .
Save only the variables whose names match the regular expressions, specified as character vectors or strings. For example, saves only the variables in the file whose names begin with or .
Store the fields of the scalar structure specified by as individual variables in the file. For example, saves the scalar structure, .
Store the specified fields of the specified scalar structure as individual variables in the file. For example, saves the fields and .
Store only the fields whose names match the regular expressions, specified as character vectors or strings.

&#; File format
(default) | | | |

File format, specified as one of the following. When using the command form of , you do not need to enclose the input in single or double quotes, for example, .

Value of File Format

Binary MAT-file format.

Text format with 8 digits of precision.

Tab-delimited text format with 8 digits of precision.

Text format with 16 digits of precision.

Tab-delimited text format with 16 digits of precision.

For MAT-files, data saved on one machine and loaded on another machine retains as much accuracy and range as the different machine floating-point formats allow.

Use one of the text formats to save MATLAB numeric values to text files. In this case:

  • Each variable must be a two-dimensional array.

  • The output includes only the real component of complex numbers.

  • MATLAB writes data from each variable sequentially to the file. If you plan to use the function to read the file, all variables must have the same number of columns. The function creates a single variable from the file.

If you specify a text format and any variable is a two-dimensional character array, then MATLAB translates characters to their corresponding internal ASCII codes. For example, appears in a text file as:

e+ e+ e+

When saving to a remote location, only supports specifying as .

Data Types: |

&#; MAT-file version
(default) | | |

MAT-file version, specified as one of the following. When using the command form of , you do not need to enclose the input in single or double quotes.

Value of Loads in MATLAB VersionsSupported FeaturesCompressionMaximum Size of Each Variable
(Rb) or later

Saving and loading parts of variables, and all Version 7 features. Version also supports saving variables without compression using the option.

Yes (default)≥ 2 GB on bit computers
(R14) or later

Unicode® character encoding, which enables file sharing between systems that use different default character encoding schemes, and all Version 6 features. Version 7 also supports saving variables without compression using the option.

Yes (default)2^31 bytes per variable
5 (R8) or later

N-dimensional arrays, cell arrays, structure arrays, variable names longer than 19 characters, and all Version 4 features.

No2^31 bytes per variable
All

Two-dimensional , character, and sparse arrays.

No,, elements per array, and 2^31 bytes per variable

If any data items require features that the specified version does not support, MATLAB does not save those items and issues a warning. You cannot specify a version later than your current version of MATLAB software.

Note

Version MAT-files use an HDF5 based format that requires some overhead storage to describe the contents of the file. For cell arrays, structure arrays, or other containers that can store heterogeneous data types, Version MAT-files are sometimes larger than Version 7 MAT-files.

To view or set the default version for MAT-files, go to the Home tab and in the Environment section, click Preferences. Select > > and then choose a MAT-file save format option.

Data Types: |

Limitations

  • When working with remote data, the function:

    • does not support saving to HDFS&#x;

    • does not support saving workspace variables in any format other than as a MAT-file.

Tips

  • For more flexibility in creating ASCII files, use .

  • Saving graphics objects with the function can result in a large file since the file contains all the information required to regenerate the object.

  • Avoid saving figures with the function. Use the function instead. Using to save a figure in Rb or later makes MAT-file inaccessible in earlier versions of MATLAB. If you use to save a figure, then the function displays a warning message. Delete any figures before using . Keep in mind that the figures might not be directly in your workspace. For example, they might be stored in a structure or in the workspace of a callback function.

Introduced before Ra

You have a modified version of this example. Do you want to open this example with your edits?

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web site

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Contact your local office

Sours: https://www.mathworks.com/help/matlab/ref/save.html

File matlab save

MATLAB Function ReferencePrevious page   Next Page
save

Save workspace variables on disk

Graphical Interface

As an alternative to the function, select Save Workspace As from the File menu in the MATLAB desktop, or use the Workspace browser.

Syntax

  • save save('filename') save('filename', 'var1', 'var2', ) save('filename', , 's') save('filename', , 's', 'f1', 'f2', ) save(, expr1, expr2, ) save(', '') save filename var1 var2

Description

by itself stores all workspace variables in a binary format in the current directory in a file named . Retrieve the data with . MAT-files are double-precision, binary, MATLAB format files. They can be created on one machine and later read by MATLAB on another machine with a different floating-point format, retaining as much accuracy and range as the different formats allow. They can also be manipulated by other programs external to MATLAB.

stores all workspace variables in the current directory in . To save to another directory, use the full pathname for the . If is the special string , the command sends the data as standard output.

saves only the specified workspace variables in . Use the wildcard to save only those variables that match the specified pattern. For example, saves all variables that start with .

saves all fields of the scalar structure as individual variables within the file .

saves as individual variables only those structure fields specified (, , ).

saves those variables that match any of the regular expressions, , etc.

enables you to make use of other data formats available with the function. See the following table.

Format
How Data Is Stored

The specified existing MAT-file, appended to the end. See Remarks, below.

8-digit ASCII format

digit ASCII format

Delimits with tabs

digit ASCII format, tab delimited

Binary MAT-file form (default)

A format that MATLAB Version 4 can open

A format that MATLAB Version 6 and earlier can open

is the command form of the syntax.

Remarks

By default, MATLAB compresses the data it saves to MAT-files. MATLAB also uses Unicode character encoding when saving character data. Specify the option if you want to disable both of these features for a particular operation. If you save data to a MAT-file that you intend to load using MATLAB Version 6 or earlier, then you must specify the option when saving.

To override the compression and Unicode setting for all of your MATLAB sessions, use the Preferences dialog box. Open the Preferences dialog and select General and then MAT-Files. To disable data compression and Unicode encoding, click Ensure backward compatibility (-v6). To turn these features back on, click Use default features (Unicode and compression).See General Preferences for MATLAB in the Desktop Tools and Development Environment documentation for more information.

For information on any of the following topics related to saving to MAT-files, see Exporting Data to MAT-Files in the "MATLAB Programming" documentation:

  • Appending variables to an existing MAT-file
  • Compressing data in the MAT-file
  • Saving in ASCII format
  • Saving in MATLAB Version 4 format
  • Saving with Unicode character encoding
  • Data storage requirements
  • Saving from external programs

Examples

Example 1

Save all variables from the workspace in binary MAT-file :

Example 2

Save variables and in binary MAT-file :

  • savefile = 'test.mat'; p = rand(1, 10); q = ones(10); save(savefile, 'p', 'q')

Example 3

Save the variables and in ASCII format to a file named :

  • save('d:\mymfiles\june10','vol','temp','-ASCII')

Example 4

Save the fields of structure as individual variables rather than as an entire structure.

  • s1.a = ; s1.b = {'abc', [4 5; 6 7]}; s1.c = 'Hello!'; save newstruct.mat -struct s1; clear

Check what was saved to :

  • whos -file newstruct.mat Name Size Bytes Class a 1x1 8 double array b 1x2 cell array c 1x6 12 char array Grand total is 16 elements using bytes

Read only the field into the MATLAB workspace.

  • str = load('newstruct.mat', 'b') str = b: {'abc' [2x2 double]}

Example 5

Using regular expressions, save in MAT-file those variables with names that begin with , , or :

  • save('mydata', '-regexp', '^Mon|^Tue|^Wed');

Here is another way of doing the same thing. In this case, there are three separate expression arguments:

  • save('mydata', '-regexp', '^Mon', '^Tue', '^Wed');

Example 6

Save a by matrix uncompressed to file , and compressed to file . The compressed file uses about one quarter the disk space required to store the uncompressed data:

  • x = ones(); y = uint32(rand() * ); save c1 x y save c2 x y -compress d1 = dir('c1.mat'); d2 = dir('c2.mat'); d1.bytes ans = % Size of the uncompressed data d2.bytes ans = % Size of the compressed data d2.bytes/d1.bytes ans = % Ratio of compressed to uncompressed

Example 7

This example is similar to the last one, except that it saves one variable uncompressed, and then a second variable compressed to the same MAT-file. It then loads this data back into the MATLAB workspace:

  • x = ones(); y = uint32(rand() * ); save c1 x; save c1 y -compress -append; d = dir('c1.mat'); d.bytes ans = clear load c1 whos Name Size Bytes Class x x double array y x uint32 array Grand total is elements using bytes

See Also

, , , , , , ,


Previous page  run saveas Next page

© The MathWorks, Inc.


Sours: http://matlab.izmiran.ru/help/techdoc/ref/save.html
How to Create, Save and Run m-file in MATLAB (Part-22)-- MATLAB for beginners

function savefile(file,path,format,index)

function savefile saves workspace variable FILE as a formatted matrix FILENAME to disk.

Input:
FILE workspace variable
PATH path and filename of saved FILE (output)

FORMAT Field Width and Precision Specifications of output

INDEX Conversion characters
Conversion characters specify the notation of the output.
SpecifierDescription:
c Single character%dDecimal notation (signed)
e Exponential notation (using a lowercase e as in e+00)
E Exponential notation (using an uppercase E as in E+00)
f Fixed-point notation
g The more compact of e or f , as defined in [2]. Insignificant zeros do not print.
G Same as %g, but using an uppercase E
i Decimal notation (signed)
o Octal notation (unsigned)
s String of characters
u Decimal notation (unsigned)
x Hexadecimal notation (using lowercase letters a-f)
X Hexadecimal notation (using uppercase letters A-F)

example
file1=rand(3,5);
savefile (file1,'d:\output.txt',,'f')

Sours: https://www.mathworks.com/matlabcentral/fileexchange/savefile

You will also be interested:

Desktop Tools and Development EnvironmentPrevious page   Next Page

Saving M-Files

After making changes to an M-file, you see an asterisk (*) next to the filename in the title bar of the Editor/Debugger. This indicates there are unsaved changes to the file.

To save the changes, use one of the Save commands in the File menu:

  • Save--Saves the file using its existing name. If the file is newly created, the Save file as dialog box opens, where you assign a name to the file before saving it. Another way to save is by using the Save button on the toolbar. If the file has not been changed, Save is grayed out, but you can instead use Save As from the File menu to save to a different filename.
  • Save As--The Save file as dialog box opens, where you assign a name to the file and save it. By default, if you do not type an extension, MATLAB automatically assigns the extension to the filename. If you do not want an extension, type a (period) after the filename.
  • Save All--Saves all named files to their existing filenames. For all newly created files, the Save file as dialog box opens, where you assign a name to each untitled file and save it.

You cannot save a file while in debug mode. If you try to, MATLAB displays a dialog box asking if you want to exit debug mode and then save the file. While debugging, you can execute sections of an M-file even though there are unsaved changes--see Running Sections in M-Files That Have Unsaved Changes.

    Note    Save any M-files you create and any M-files from The MathWorks that you edit in a directory that is not in the $ directory tree. If you keep your files in $ directories, they can be overwritten when you install a new version of MATLAB. Also note that locations of files in the $ directory tree are loaded and cached in memory at the beginning of each MATLAB session to improve performance. If you save files to $ directories using an external editor or add or remove files from these directories using file system operations, run   before you use the files in the current session. If you make changes to existing files in $ directories using an external editor, run before you use the files in the current session. For more information, see or Toolbox Path Caching in MATLAB.

Autosave

As you make changes to a file in the Editor/Debugger, every five minutes the Editor/Debugger automatically saves a copy of the file to a file of the same name but with an extension. The autosave copy is useful if you have system problems and lose changes made to your file. In that event, you can open the autosave version, , and then save it as to use the last good version of . For example, if you edit and do not save it for five minutes, MATLAB saves the file including the unsaved changes, to .

Use autosave preferences to turn the autosave feature off or on, to specify the number of minutes between automatic saves, and to specify the file extension and location for autosave files. For details, see Autosave Preferences for the Editor/Debugger in the online documentation."

If the file you are editing is in a read-only directory and the autosave preference for location is the source file directory, an autosave copy of the file is not made.

Deleting Autosave Files.   By default, autosave files are not automatically deleted when you delete the source file. To keep autosave to M-file relationships clear and current, it is a good practice when you rename or remove an M-file to delete or rename its corresponding autosave file.

There is a preference to Automatically delete autosave files. With this preference selected, when you close an M-file in the Editor/Debugger, MATLAB automatically deletes the corresponding autosave file.

Accessing Your Source Control System

If you use a source control system for M-files, you can access it from within the Editor/Debugger using File -> Source Control. For more information, see Source Control Interface.


Previous page  Opening a Selection in an M-File Running M-Files from the Editor/Debugger Next page

© The MathWorks, Inc.


Sours: http://matlab.izmiran.ru/help/techdoc/matlab_env/edit_dhtml


1131 1132 1133 1134 1135