Return the free space and total space on the drive, in bytes



disk_space = diskspace(filesys_object, drive_name) returns a structure containing the free space and total space on the drive, in bytes. If a drive with that name does not exist in the target computer, displays an error message.

Note: The SimulinkRealTime.fileSystem object will be removed in a future release. See the release note for file system commands to use instead. These commands use the SimulinkRealTime.openFTP function and the functions for the MATLAB ftp object.


collapse all

Return the free space and total space on the C:\ drive in the target computer.

tg = slrt;
fsys = SimulinkRealTime.fileSystem(tg);
ans = 

     freeDiskSpacebytes: 5.9889e+10
    totalDiskSpacebytes: 6.0005e+10

Input Arguments

collapse all

File system object created by using the SimulinkRealTime.fileSystem creation function.

The file system object represents the target computer file system. You work with the target computer file system from the development computer by using file system methods.

Example: fsys

Data Types: struct

Enclose the drive name in single quotation marks. The drive must exist on the target computer.

Example: 'C:\'

Data Types: char

Output Arguments

collapse all

Returns a structure containing the following fields:

  • freeDiskSpacebytes — The number of bytes of unused space on the drive.

  • totalDiskSpacebytes — The total number of bytes on the drive.

Introduced in R2016a