You could try the following steps:
1) Check the generated code and see if you can find any reference to the MAT File that you are trying to write through the 'To file' block.
2) If there are no references to the MAT File in the generated code, then it may be the case that you have 'MAT-File Logging' disabled, which is optimizing out the 'To File' block during deployable code generation. Make sure to enable it in configuration parameters "Code Generation > Advanced Parameters > MAT-File Logging" found under "All Parameters".
3) If there are references to the MAT-file in the code and you still find it is not being created, you could debug the code running on your Raspberry Pi to see what code paths are being taken that preclude the writing of the MAT file.
Hope this helps!