LOADFIXNAMES loads a mat file, fixing invalid names

버전 1.3.0.0 (14 KB) 작성자: James Tursa
Loads a mat file into the caller's workspace, fixing invalid variable and field names.
다운로드 수: 1.6K
업데이트 날짜: 2017/8/1

라이선스 보기

Building:
LOADFIXNAMES is typically self building. That is, the first time you call it, the loadfixnames.m file recognizes that the mex routine needs to be compiled and then the compilation will happen automatically.
The usage is as follows (arguments in brackets [ ] are optional):

Syntax

loadfixnames(FILENAME [,names] [,verbose])
S = loadfixnames(FILENAME [,names] [,verbose])

FILENAME = The mat file to be loaded
names = string or cell array of strings (variable name(s) to load)
verbose = 1 or 0 (optional, causes name change log to be displayed)
S = struct returned instead of loading variables into workspace

Description

LOADFIXNAMES loads a mat file into the workspace, fixing invalid names. All invalid characters are replaced with an underscore. Also, if the first character is not a letter, an 'A' is added to the front. If the variable is a structure, fixes the field names also. In the case of field names, the name length is kept constant. So if a field name begins with a digit it will be replaced with 'A' - 'J' instead. If the field name begins with an invalid non-digit it will be replaced with 'A' - 'Z' or 'a' - 'z' (letters are cycled in an attempt to avoid name clashes).

Limitations: The current renaming scheme makes a mild attempt to avoid name clashes, but does not guarantee this.

See the companion function SAVEBADNAMES for a test function that will intentionally create a mat file with invalid names.

Building:

SAVEBADNAMES is typically self building. That is, the first time you call it, the savebadnames.m file recognizes that the mex routine needs to be compiled and then the compilation will happen automatically.

The usage is as follows (arguments in brackets [ ] are optional):

Syntax

savebadnames(FILENAME [,verbose])

FILENAME = The mat file to be saved
verbose = 1 or 0 (optional, causes name change log to be displayed)

Description

SAVEBADNAMES saves a mat file using intentionally invalid names.

인용 양식

James Tursa (2024). LOADFIXNAMES loads a mat file, fixing invalid names (https://www.mathworks.com/matlabcentral/fileexchange/42274-loadfixnames-loads-a-mat-file-fixing-invalid-names), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2006b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기
태그 태그 추가

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.3.0.0

Fixed a bug in a name string copy. Also added smarter character replacement for upper ASCII characters.

1.1.0.0

Added code to deal with duplicate variable names

Added capability to return a struct

1.0.0.0