Eric
Eric

Reputation: 996

How to create blank .mat file from terminal?

Is there any way to create an empty .mat file from a terminal session? Basically, what I am doing is brain graph analysis. The software I am using, if an entire brain is scrubbed (ie, if the displacement of the brain is greater than a certain threshold) the output file will be left out or will be very small. When analyzing, however, I need to be able to eliminate both subjects from the analysis if the entire brain is scrubbed/too much of the brain is scrubbed. To accomplish this, the easiest way would be to simply check the dimensions of the output file within matlab, and if they are below the arbitrary threshold I decide then both subjects will just be skipped over for analysis. The issue is, I can easily check if a file contains too few remaining frames, however, if the resulting file contains no frames, it will entirely just not exist. As the outputs are all sorted, the only thing I need to do is check consecutive files' dimensions, and if one of the files does not contain enough values, then I can simply skip over it entirely. Simply touching a blank file obviously will not work, since it will not contain any encoding. I hope this is a good explanation for my motivation to do this, and if any of you know of any suggestions, please let me know.

Upvotes: 1

Views: 5469

Answers (2)

Sebastian Thormann
Sebastian Thormann

Reputation: 11

Saving the contents of an empty struct creates an empty .mat file:

emptyStruct = struct;
save('myFile.mat','-struct','emptyStruct');

Upvotes: 1

Rafael Monteiro
Rafael Monteiro

Reputation: 4549

A simple solution would be to create an empty file from Matlab and duplicate the file when needed from the console.

Just open Matlab, set to the destination folder and type this:

clear all
save empty.mat

Then, when needed, copy the file from the console. :)

Upvotes: 2

Related Questions