Clear Filters
Clear Filters

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

2 views (last 30 days)
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)

Answers (1)

Tommy on 21 May 2020
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?


Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!