Automating conversion with sm4tomatlab
skippedFiles = sm4tomatlab( )
sm4tomatlab.m is a script that allows conversion of entire folders of .sm4 files in one go using sm4reader.
How to use
With both sm4reader and sm4tomatlab in a proper MATLAB search path so they can be called from the command line*, just enter sm4tomatlab into the line, and it will act on the currently active MATLAB folder. As each file is converted, the formatted .mat file for each .sm4 is saved into the current folder with the same filename as the original .sm4 file.
*For details on how to add user functions / folders to MATLAB paths, making your own startup.m may be useful.
A note on filenames
The .mat files which are saved cannot contain extra periods, or MATLAB will return errors when using it. Therefore, any ' . ' in the file name is automatically replaced with ' _ ' for the saved .mat.
Skipped files and errors
There are some important considerations about sm4tomatlab's behaviour, dictated by which kinds of .sm4 data sm4reader is capable of formatting. .sm4 files which lack the data structures sm4reader reads and formats are skipped, with names of the skipped files output into the array skippedFiles. Which files are readable and which are skipped is dependent on having thought of all file types and exceptions. If a new exception not accounted for is encountered, then the program will return an error.
Our list of converted and skipped files is not exhaustive, but based on our needs. If you find a new type of data structure in the .sm4 then you will need to change the sm4reader program, not sm4tomatlab. sm4tomatlab will skip files for which sm4reader returns a formatoutfile value of 'None' instead of a structure.
sm4tomatlab.m is a script that allows conversion of entire folders of .sm4 files in one go using sm4reader.
How to use
With both sm4reader and sm4tomatlab in a proper MATLAB search path so they can be called from the command line*, just enter sm4tomatlab into the line, and it will act on the currently active MATLAB folder. As each file is converted, the formatted .mat file for each .sm4 is saved into the current folder with the same filename as the original .sm4 file.
*For details on how to add user functions / folders to MATLAB paths, making your own startup.m may be useful.
A note on filenames
The .mat files which are saved cannot contain extra periods, or MATLAB will return errors when using it. Therefore, any ' . ' in the file name is automatically replaced with ' _ ' for the saved .mat.
Skipped files and errors
There are some important considerations about sm4tomatlab's behaviour, dictated by which kinds of .sm4 data sm4reader is capable of formatting. .sm4 files which lack the data structures sm4reader reads and formats are skipped, with names of the skipped files output into the array skippedFiles. Which files are readable and which are skipped is dependent on having thought of all file types and exceptions. If a new exception not accounted for is encountered, then the program will return an error.
Our list of converted and skipped files is not exhaustive, but based on our needs. If you find a new type of data structure in the .sm4 then you will need to change the sm4reader program, not sm4tomatlab. sm4tomatlab will skip files for which sm4reader returns a formatoutfile value of 'None' instead of a structure.