MATLAB UITABLE Column Width GUIDE - Error Message

2 views (last 30 days)
Hi Everyone,
So I have read at least 30 posts on how to change the column width of a uitable in MATLAB, and I've tried everything. Here is what I currently have:
% --- Executes during object creation, after setting all properties.
function uitable1_CreateFcn(hObject, eventdata, handles)
% hObject handle to uitable1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
ssizetemp = get(0,'ScreenSize');
ssize = ssizetemp(3);
ssize = ssize * 0.11835443037974684; % Where x is the size of the table relative to the screen.
%If the table occupies the whole screen from left to right, it's a 1.
%This works best when you specified the position of the table with normalized units in the
%first place. That way you know the exact value of x.
set(handles.uitable1,'ColumnWidth',{0.5*ssize,0.5*ssize});
%Sample table with 2 columns. Adjust the numbers whatever way you want making sure
%they add up to 1.
% Update handles structure
guidata(hObject, handles);
and I keep getting this error message:
Attempt to reference field of non-structure array.
Error in BatchProcessingTool>uitable1_CreateFcn (line 116)
set(handles.uitable, 'Data', data, 'ColumnFormat',{0.5*ssize,0.5*ssize});
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in BatchProcessingTool (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)BatchProcessingTool('uitable1_CreateFcn',hObject,eventdata,guidata(hObject))
Error using struct2handle
Error while evaluating uitable CreateFcn
which I suspect is due to the function not being properly initialized. So here is my question: How can I edit the column width of a table that was created with GUIDE?
Any/all help is greatly appreciated!
Thanks,
- Yasmin

Accepted Answer

Yasmin
Yasmin on 21 Jul 2015
Found a solution thanks to a co-worker! In the uitable properties, if you click on "ColumnEditable" you can actually adjust the width of each column.

More Answers (0)

Categories

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!