Saving files in App Designer
3 views (last 30 days)
Show older comments
Hi, I am trying to save my document and I want to save my Table variable as the name I wrote in my EditField
savein=uigetdir(Name of the location);
str=strcat(savein, {'/'}, app.EditField.Value);
newstr=char(str);
Table = strjoin(app.Clasification.Data)'
newName = input (app.EditField.Value,"s")
S.(newName) = Table
save([newstr '.mat'],'-struct','S')
And I get Invalid field Name: ' '
Please help
0 Comments
Answers (1)
Riya
on 26 Feb 2025
Hi,
I understand that you are encountering an error while trying to set the variable name of “Table” to match the “EditField” value. This happens because “app.EditField.Value” may be empty or contain spaces, special characters, or numbers at the beginning, making it an “invalid structure field name”.
In MATLAB, Field names, like variable names, must begin with a letter, can contain letters, digits, or underscore characters, and are case sensitive.
To fix this, you can modify the field name to make sure it is valid. You can also use “matlab.lang.makeValidName” function which converts it to a valid name by replacing invalid characters with underscores and ensuring it does not start with a number.
newName = matlab.lang.makeValidName(strtrim(app.EditField.Value));
For more information about Generating field names from Variables, please refer to the following documentation:
Thanks!
0 Comments
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!