How to create a UITABLE in GUI using a data from matlab variable workspace
6 views (last 30 days)
Show older comments
Hi,
I'm still a beginner in MATLAB so hope this vast community can help me figure out how to solve my problem.
I'm creating a UITABLE using MATLAB GUI, and i want the UITABLE data to be the data from a variable named Table from the variable workspace. I totally confused in which callback function that i need to put my code on??
tq in advance for helping me
0 Comments
Accepted Answer
Geoff Hayes
on 8 Jan 2015
Nik - you could put this code in either the _CreateFcn for the uitable, or the _OpeningFcn of your GUI. If the former, then the code would be something like
function uitable1_CreateFcn(hObject, eventdata, handles)
% check to see if the variable exists in the base workspace
if evalin('base','exist(''Table'',''var'')')
% get the variable from the base workspace and save it to the table
data = evalin('base','Table');
set(hObject,'Data',data);
end
The above code would be near-identical for the _OpeningFcn - all you would have to do is replace hObject with handles.uitable1.
Note how the above code checks to see if the variable exists before trying to access it using evalin.
In the above example, Table was created in the workspace as
Table = randi(255,12,4);
2 Comments
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!