MATLAB: Simulink Real-Time Data Logging with File Scope

directorylogslrt

I am using a File Scope in my Simulink Real-Time model to log data. However, after simulation no data has been logged. Additionally, when trying to access the file system of my target from MATLAB, I get the following error:
>> tg = slrt;
>> fsys = SimulinkRealTime.fileSystem(tg);
>> dir(fsys)
Error: -8: invalid file system

Best Answer

In the File Scope, specify the full path of the data logging file, e.g. 'D:\data.dat'. If only the file name is entered, the file scope automatically tries to write to the 'C:\' drive. If the target has no 'C:\' drive, the data will not be written anywhere. More information on File Scope usage can be found here:
Additionally, if you omit the drive letter from the "dir" command it assumes that the folder path is relative to the default drive. Therefore, please specify the correct drive letter for your computer if it has no "C:\" drive, for example:
>> dir(fsys, 'D:\')