Reference to non-existent field error
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello Everyone. I am getting an error related to
Reference to non-existent field 'mystructdata'.
Error in GUI_ParametersFinal>pushbutton_Save_Callback (line 120)
data = handles.mystructdata;
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in GUI_ParametersFinal (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)GUI_ParametersFinal('pushbutton_Save_Callback',hObject,eventdata,guidata(hObject))
When I do not type any value inside the edit text boxes, it gives me this error when saving inside the mat file. How can I remove this error and save another value only, which is needed and not related to my struct fields.
My code for pushbutton save_ callback is this:
function pushbutton_Save_Callback(hObject, eventdata, handles)
startingFolder = pwd
defaultFileName = fullfile(startingFolder, '*.mat');
[baseFileName, folder] = uiputfile(defaultFileName, 'Select mat file');
if baseFileName == 0
return;
end
fullFileName = fullfile(folder, baseFileName);
if (exist('str') == 0); or if(exist('handles.mystructdata') == 0)
data.Level = handles.Level;
save(fullFileName,'data')
else
data = handles.mystructdata;
data.Level = handles.Level;
save(fullFileName,'data');
end
If I dont type anything inside the edit text boxes, I will like these text boxes to be ignored and just save that text box value in which I typed a value using structs fields. Thank you so much.
1 commentaire
Walter Roberson
le 18 Oct 2019
if (exist('str') == 0); or if(exist('handles.mystructdata') == 0)
That is not correct syntax for or.
if ~exist('str', 'var') || ~isfield(handles, 'mystructdata')
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graphics Object Properties 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!