Saving files in App Designer
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Riya
am 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 Kommentare
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!