Generate a table in Matlab GUI (matlab 7.0.1)

조회 수: 2 (최근 30일)
Subhiksha
Subhiksha 2013년 9월 18일
Hi all,
I have an excel sheet containing 30 rows and 30 columns. Using Matlab Guide, I read the excel sheet. Now I want to display the contents of the excel sheet as a table (figure) containing 30 rows and 30 columns.
I tried with uitable.
p1 = xlsread('C:\Documents and Settings\user\Desktop\sample.xls','Sheet1'); f = figure('Position',[100 100 752 350]); t = uitable('Parent',f,'Position', [ 25 25 700 200]); set(t, 'Data', p1)
On executing the above code, I get the following error: ??? Invalid handle object.
What am I supposed to do???
I am using Matlab 7.0.1.
Thanks in advance for the help.
  댓글 수: 1
Subhiksha
Subhiksha 2013년 9월 19일
Finally, found a way to create a table in Matlab 7.0.1
This is what I did.
data = xlsread('C:\Documents and Settings\user\Desktop\sample.xls','Sheet1'); colnames = {'FP1', 'FP2', 'F7', 'F3', 'Fz', 'F4', 'F8', 'FT7', 'FC3', 'FCz', 'FC4', 'FT8', 'T3', 'T4', 'TP7', 'TP8', 'C3', 'Cz', 'C4', 'CP3', 'CPz', 'CP4', 'T5', 'P3', 'Pz', 'P4', 'T6', 'O1', 'Oz', 'O2'}; t = uitable(data, colnames,'Position', [100 100 1000 500]);

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

답변 (2개)

ES
ES 2013년 9월 18일
Insert a uitable in your GUI by name say TableDemo. then read data from xls like you have done,
p1 = xlsread('C:\Documents and Settings\user\Desktop\sample.xls','Sheet1');
and
set(handles.TableDemo,'Data',p1);
  댓글 수: 2
Subhiksha
Subhiksha 2013년 9월 18일
Thank you so much for your time. I have put this code in a callback function where I need the table.
p1 = xlsread('C:\Documents and Settings\user\Desktop\sample.xls','Sheet1'); f = figure('Position', [100 100 752 350]); tabledemo = uitable('Position', [ 25 25 700 200]); set(handles.tabledemo,'Data',p1)
On executing the above code, I get this error:
Reference to non-existent field 'tabledemo'.
What should be done??
ES
ES 2013년 9월 18일
Do you really need to create the table dynamically? You cab just place the table in the GUI DE and then call it using its handles.

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


Jan
Jan 2013년 9월 19일
handles.tabledemo = uitable('Position', [ 25 25 700 200]);
set(handles.tabledemo,'Data',p1);
guidata(f, handles); % Store handles in the ApplicationData of f for later use

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by