- MATLAB Windows
- File Types
|
Types of Files
There are mainly five different types of files for storing data or programs:
a) M File
M-Files are standard ASCII text files, with a .m extension to the filename. There are two types of these files: script files and function files. Most programs user write in MATLAB Editor Window are saved as M-files..
b) Mat File
Mat-files are binary data files, with a .mat extension to the filename. Mat-files are created by MATLAB when user save data of Workspace window with the save command.
c) Figure File
Figure files are binary files with a .fig extension that can be opened again in MATLAB as figures. Such files are created by saving a figure in this format using the Save or Save As. A fig-file contains all the information required to create the figure. Such files can be open filename.fig command
d) P File
P-files are compiled M-files with a .p extension that can be executed in MATLAB. These files are created with the pcode command. If use develop an application that other people can use but user do not want give them the source code (M-files), then use give them the corresponding p-code or the p-file.
e) Mex File
Mex-files are MATLAB callable Fortran and C programs, with a .mex extension to the filename.
Notes for working in the Command Window:
1. Where to type commands?
All MATLAB commands or expression are entered in the command window at the MATLAB prompt (>>).
2. How to execute commands?
To execute a command or statement, you must press return or enter at the end.
3. What to do if the command is very long?
If a command is too long to fit in one line, it can be continued to the next line by typing three periods … (called an ellipsis) and pressing the Enter key.
4. How to name variables?
Name of variables must begin with a letter. After the first letter, any number of digits or underscores may be used.
5. What is the precision of computation?
All computations are carried out internally in double precision unless specified otherwise. The appearance of numbers on the screen, however, depends on the format in use.
6. How to control the display format of the output?
The output appearance of floating point numbers (number of digits after the decimal, etc.) is controlled with the format command.
7. How to suppress the screen output?
A semicolon (;) at the end of a command suppress the screen output, although the command is carried out and the result is saved in the variable assigned to the command or in the default variable ans.
8. How to recall previously typed commands?
- A previously typed command can be recalled to the command prompt with the up-arrow key (↑). When the command is displayed at the command prompt, it can be modified if needed and executed. The down-arrow key (↓) can be used to move down the previously typed commands.
- Double click on any command in the command history sub window to execute it in the command window.
9. What about comments?
When the symbol % (percent symbol) is typed in the beginning of a line, the line is designed as a comment. This means that when the Enter key is pressed the line is not executed. The % character followed by text (comment) can also be typed after a command (in the same line). This has no effect on the execution of the command.
Special Notes:
1. It is not possible to go back to previous line in the command window, make a correction, and then re-execute the command window.
2. Several commands can be typed in the same line. This is done by typing a comma between the commands. When the Enter key is pressed the commands are executed from left to right.
3. Once is command is typed and the Enter key is pressed, the command is executed However, only the last command is executed. Everything executed previously is unchanged.
No comments:
Post a Comment