How can I export text and numeric data from excel to uitable (GUI element)

2 ビュー (過去 30 日間)
Gabriel Aviles
Gabriel Aviles 2020 年 5 月 20 日
回答済み: Tommy 2020 年 5 月 21 日
Hello.I made a simple GUI where I want to be able to display text-numeric data using uitable. I tried using readtable but the outcome is an error.
%Error Message
Error using matlab.ui.control.Table/set
Functionality not supported with figures created with the figure function. For more information, see Graphics
Support in App Designer.
%Part of the code with Data
% --- Executes just before untitled is made visible.
function untitled_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to untitled (see VARARGIN)
% Choose default command line output for untitled
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
x = readtable('Informacion_Psicologica1.xlsx')
set(handles.uitable3, 'Data',x)

回答 (1 件)

Tommy
Tommy 2020 年 5 月 21 日
According to the docs, when you set the Data property of a uitable created with the figure function, you must set it to a numeric array, logical array, or cell array.
The Data property of a uitable created with the uifigure function, on the other hand, can be set to a table, which is what you are trying to do (as readtable returns a table).
Does converting to a cell array with table2cell fix your problem?

カテゴリ

Help Center および File ExchangeDialog Boxes についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by