Hello, I'm trying to export a data structure with a GUI and then load it in the GUI again using uisave and uiopen. I'm getting the following error when I'm trying to use the data structure once it is loaded: "The class struct has no Constant property or Static method…"
The idea behind using uisave and uiopen is to have a UI for saving and loading data.
When I'm in debbug mode, I can do whatever I want with the data structure once it is loaded in the GUI without getting the error. I guess that the problem is because I'm using the structure in a GUI and I'm doing something wrong with uiopen…
Here is the code and the way it is meant to be used: Write something in the table, then press the export button to export the data. Erase the data in the table and then load the data with the load button. Expected result: Retrieve the exported data and display in the table.
%General definition of the GUI
function TEST_GUIclear allclcclose allhandles.F=figure;handles.data_table=[0 0 0;0 0 0;0 0 0];handles.table=uitable('parent',handles.F,'units','normalized','position',[0.5 0.3 0.4 0.4],... 'data',handles.data_table,'columnEditable',[true]);uicontrol('parent',handles.F,'style','pushbutton','string','Export','unit','normalized','position',[0.2 0.55 0.2 0.1],... 'callback',{@export_data});uicontrol('parent',handles.F,'style','pushbutton','string','Load','unit','normalized','position',[0.2 0.45 0.2 0.1],... 'callback',{@select_data});guidata(handles.F,handles);%Export data callback
function export_data(src,eventdata)handles=guidata(src);data=get(handles.table,'data');struct.data_table=data;uisave('struct','new_file.mat')guidata(handles.F,handles);%Load data callback
function select_data(src,eventdata)handles=guidata(src);try uiopen('*.mat')catch warndlg('Error - Try Again') beep returnenddata=struct.data_table;handles.data_table=data;set(handles.table,'data',handles.data_table);guidata(handles.F,handles);
Best Answer