필터 지우기
필터 지우기

How can I display a table in GUI?

조회 수: 2 (최근 30일)
Billie Jean
Billie Jean 2016년 11월 9일
답변: Jan 2016년 11월 10일
I need to read data from a txt file and then put it in a table in GUI. I have tried getting it in a cell array and then use it but the table does not take the cell array as data input. I have then tried using a matrix but I have characters and integers in the txt file and cell2mat does not work. How can I handle that?
handles.fileName = uigetfile;
handles.fid=fopen(handles.fileName);
handles.cellArray=textscan(handles.fid, '%s %f %f %f');
handles.matrix=cell2mat(handles.cellArray);
handles.f = figure;
handles.t = uitable(handles.f); %creating empty table
handles.t.Data=handles.matrix; %assigning the data
  댓글 수: 1
Henry Giddens
Henry Giddens 2016년 11월 9일
Assuming that all entries in the cell array are either numeric, logical or string, (with a single entry in each cell), you should be able to set the uitable data property to the cellArray

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

답변 (1개)

Jan
Jan 2016년 11월 10일
Try:
C = textscan(handles.fid, '%s %f %f %f');
handles.cellArray = cat(2, C{:});

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by