GetExtension

Gets the extension of a file.

You are now following this Submission

Gets the extension of a filename. The extension is assumed to be the last dot of the filename and all characters following the last dot. If there is no dot, then FileExtension is empty.

This code seems useful when you allow the user to select a file (eg. using uigetfile), and you want to do different things based on the extension of the file the user has chosen. You could do this with the index options of uigetfile, but this gives a way for the user to see all files in a directory, and still determine the type of file that was chosen.

Cite As

John McArthur (2026). GetExtension (https://uk.mathworks.com/matlabcentral/fileexchange/15537-getextension), MATLAB Central File Exchange. Retrieved .

Acknowledgements

Inspired by: findfiles

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0