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

 採用された回答

Geoff Hayes
Geoff Hayes 2015 年 1 月 8 日
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 件のコメント

Nik
Nik 2015 年 1 月 8 日
thanz a lot sir...you've solved my problem. thanks again :)
Geoff Hayes
Geoff Hayes 2015 年 1 月 9 日
Glad I was able to help, Nik!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeWorkspace 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