Reference to non-existent field error
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Walter Roberson
am 18 Okt. 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')
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Text Files 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!