Close one or more open files
Syntax
*
status = fclose(fid)
status = fclose('all')
Description
status = fclose(fid) closes the specified file, if it is open, returning 0 if successful and -1 if unsuccessful. Argument fid is a file identifier associated with an open file. (See fopen for a complete description of fid).
status = fclose('all') closes all open files, (except standard input, output, and error), returning 0 if successful and -1 if unsuccessful.
fclose (serial)
Disconnect a serial port object from the device
Syntax
*
fclose(obj)
Arguments
obj
A serial port object or an array of serial port objects.
Description
fclose(obj) disconnects obj from the device.
Remarks
If obj was successfully disconnected, then the Status property is configured to closed and the RecordStatus property is configured to off. You can reconnect obj to the device using the fopen function.
An error is returned if you issue fclose while data is being written asynchronously. In this case, you should abort the write operation with the stopasync function, or wait for the write operation to complete.
If you use the help command to display help for fclose, then you need to supply the pathname shown below.
*
help serial/fclose
Example
This example creates the serial port object s, connects s to the device, writes and reads text data, and then disconnects s from the device using fclose.
*
s = serial('COM1');
fopen(s)
fprintf(s, '*IDN?')
idn = fscanf(s);
fclose(s)
At this point, the device is available to be connected to a serial port object. If you no longer need s, you should remove from memory with the delete function, and remove it from the workspace with the clear command.
No comments:
Post a Comment