Example Analysis of Files in matlab GUI
This article mainly introduces the matlab GUI file example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Low-level file I/O1. File reading
Fopen: file openin
Fclose: file closin
Fread: reading binary data
Fwrite: binary file writ
Fgetl: read line by line
Fgets: read line by line
Fscanf: format read:
Fprintf: formatting write
Clear all
[fid,message] = fopen ('file2.txt','w+')
If fid==-1
Disp (message)
Else
Fwrite (fid,'good moring','uint8')
End
Fclose (fid)
[fid,message] = fopen ('file2.txt','r')
If fid==-1
Disp (message)
Else
A1=fread (fid)
A1'
Disp (char (A1)')
End
Fclose (fid)
Read matrix data
Read the text file line by line
With fgetl () and fgets (), you can read data line by line from a formatted file file and save it as a string. The basic functions of the two functions are the same, except that the function fgets () copies a new line of characters into the string, while the function fgetl () is not.
Clear all
[fid,message] = fopen ('file3.txt','w+')
If fid==-1
Disp (message)
Else
Magic (4)
Fwrite (fid,magic (4), 'int32')
End
Fclose (fid)
[fid,message] = fopen ('file3.txt','r')
If fid==-1
Disp (message)
Else
A1=fread (fid, [3 3], 'int32')
A1
End
Fclose (fid)
two。 Internal control of documents
When you open a file, a file identity is generated that indicates the current location in the file. It is done by controlling the file identity to read and write the file.
Function
Description
Feof
Test whether to reach the end of the file
Fseek
Move the file identity to a specific location
Frewind
Move the file identity to the file header
Ftell
Get the location of the document identification
Thank you for reading this article carefully. I hope the article "sample Analysis of documents in matlab GUI" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!