필터 지우기
필터 지우기

Format bank uitable

조회 수: 17 (최근 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에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by