Format bank uitable

10 次查看(过去 30 天)
john
john 2012-1-14
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);

回答(2 个)

Jan
Jan 2012-1-14
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 个评论
Walter Roberson
Walter Roberson 2012-1-14
"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}
john
john 2012-2-14
So...how can I store value "sym" into uitable?

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2012-1-14
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 个评论
john
john 2012-1-14
1. I'm not sure...can I change format in my program ( durning calculation of my program?
2. You wrote "supports two numeric formats,, 'numeric', and 'bank' " ...So can I have format bank? because I want format bank
Walter Roberson
Walter Roberson 2012-1-14
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Genomics and Next Generation Sequencing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by