How to create a UITABLE in GUI using a data from matlab variable workspace

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

 채택된 답변

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

thanz a lot sir...you've solved my problem. thanks again :)
Glad I was able to help, Nik!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

질문:

Nik
2015년 1월 6일

댓글:

2015년 1월 9일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by