Load stored handles data to an other function

5 vues (au cours des 30 derniers jours)
Astro_Anthony
Astro_Anthony le 17 Juin 2020
Commenté : Astro_Anthony le 18 Juin 2020
Hi everybody,
I am beginner in Matlab GUI and I have a problem to load stored data in handles, in an other function, let me explain :
Basicaly, I use a pushbutton to load a .csv file, inside the pushbutton function, I use a function (called Loading) who transform my csv file to a new table, then I stored this new table to handles because I need it for other function:
function pushbutton1_Callback(hObject, eventdata, handles)
[file,path] = uigetfile('*.csv', 'Select log file');
set(handles.pushbutton1,'String', file);
Pathfile = ([path file]);
NewTable = Loading(Pathfile);% NewTable store data from "Loading" function
handles.NewTable = NewTable;% Save NewTable to handles to use it in other function.
guidata(hObject, handles);
Then, in other pushbutton function, I need to call the data from NewTable for an other function :
function pushbutton2_Callback(hObject, eventdata, handles)
ValueMin1 = get(handles.ValueMin1txt, 'String');% Load value min from user
ValueMax1 = get(handles.ValueMax1txt, 'String');% Load value max from user
DataNeed = get(handles.NewTable);% Assign NewTable data strored in handles in DataNeed
FinalTable = DataSort(ValueMin1,ValueMax1,DataNeed);
handles.FinalTable = FinalTable;
guidata(hObject, handles);
But when I whould like to call the data store in handles I have this error message:
"For a call to GET of the form "v = get(h)", the elements of h must all be of the same class."
I think that something is missing in this ligne:
DataNeed = get(handles.NewTable);
If I compare with call for ValueMin, for example, it the type value is missin for the NewTable call but I don't know the type of the data... It a double value but when I trying to write:
DataNeed = get(handles.NewTable, 'Double');
It doesn't work... I think that there is something that I don't understand but I don't know what...
I already checked other post, but none of the solution helped me to resolve my problem.
Thanks a lot for your help and tell me if something is not clear.

Réponse acceptée

Stephen23
Stephen23 le 18 Juin 2020
"I think that something is missing in this ligne"
Actually you already have too much on that line. Try this:
DataNeed = handles.NewTable;
The get is not required because NewTable is just some array, it is not a graphics object.
  1 commentaire
Astro_Anthony
Astro_Anthony le 18 Juin 2020
Thanks a lot! It works now.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur App Building 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!

Translated by