Format bank uitable
11 views (last 30 days)
Show older comments
Hi,
please for help.
How can I set up format short or format bank for my program for uitable? I still have format long, but I need form short.
Maybe problem is cell... maticaA=cell(3,3);....but I will need it later to insert numbers and strings into table uitable1.
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
h=findobj(0,'Type','figure','Tag','figure1');
UserData=get(h,'UserData');
format bank;
maticaA=cell(3,3);
for i=1:3
for j=1:3
maticaA{i,j}='0.02545455454';
end
end
UserData.maticaA=maticaA;
columneditable(1:3)=true;
set(handles.uitable1,'Data',maticaA,'ColumnEditable', columneditable,'ColumnWidth',{40},'visible','on');
va=size(UserData.maticaA);
for i=1:va(1)
for j=1:va(2)
A(i,j)=sym(UserData.maticaA{i,j});
end
end
C=simple(A);
vys=size(C);
for i=1:vys(1)
for j=1:vys(2)
vysledok(i,j)=cellstr(char(C(i,j)));
end
end
set(handles.uitable12,'Data',vysledok,'ColumnFormat',{'bank','bank','bank'},'ColumnEditable', columneditable,'ColumnWidth',{150},'visible','on');
set(h,'UserData',UserData);
guidata(hObject, handles);
0 Comments
Answers (2)
Jan
on 14 Jan 2012
It looks like you actually use the 'bank' ColumnFormat already.
See:
uitable('Data', {1.234567890, 1.234567890, 1.234567890, single(1.234567890)},...
'ColumnName', {'long', 'numeric', 'bank', 'numeric'},...
'ColumnFormat', {'long', 'numeric', 'bank', 'numeric'}, ...
'Units','normalized','Position', [0.1 0.1 0.9 0.9]);
3 Comments
Walter Roberson
on 14 Jan 2012
"format bank" applies to numeric values. You do not store numbers in either of your uitables: you store strings.
maticaA{i,j}='0.02545455454'
is a string.
vysledok(i,j)=cellstr(char(C(i,j)));
stores a string at vysledok{i,j}
Walter Roberson
on 14 Jan 2012
uitable only supports two numeric formats,, 'numeric', and 'bank'. There is no possibility to change what either of those formats looks like.
If you need anything more specific, you need to make that column a string and format the numbers as string yourself (and remembering to convert back to numeric if you ever need to fetch them.)
2 Comments
Walter Roberson
on 14 Jan 2012
My mistake, anything acceptable to the "format" command can be used.
'short' and 'bank' are acceptable.
http://www.mathworks.com/help/techdoc/ref/uitableproperties.html#brglhyc
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!