How can I display a table in GUI?

3 vues (au cours des 30 derniers jours)
Billie Jean
Billie Jean le 9 Nov 2016
Réponse apportée : Jan le 10 Nov 2016
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 commentaire
Henry Giddens
Henry Giddens le 9 Nov 2016
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

Connectez-vous pour commenter.

Réponses (1)

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

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by