Saving files in App Designer
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Riya
le 26 Fév 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 commentaires
Voir également
Catégories
En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!