Format bank uitable

6 visualizzazioni (ultimi 30 giorni)
john
john il 14 Gen 2012
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);

Risposte (2)

Jan
Jan il 14 Gen 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 Commenti
Walter Roberson
Walter Roberson il 14 Gen 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}
john
john il 14 Feb 2012
So...how can I store value "sym" into uitable?

Accedi per commentare.


Walter Roberson
Walter Roberson il 14 Gen 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 Commenti
john
john il 14 Gen 2012
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 il 14 Gen 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

Accedi per commentare.

Categorie

Scopri di più su Mathematics and Optimization in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by