uitable callback: replace cell in a cell array with 'char' string value gives NAN not 'text'

조회 수: 9 (최근 30일)
I have a mat file with a cell array with various numbers and text. I load this into a uitable and give the user the opportunity to change the values of certain cells then it auto saves to csv (cell2csv). This works fine for pop-up and numeric columnn formats, but if the column format is set at 'char' 'ABC' it appears as NaN in the table/cell array.
My callback is basically: datacellarray(event.Indices) = {event.NewData}
I've tried [] {} () in various positions and tried inputting different things in the uitable cell and setting the uitable column format to no avail. I am sure it is something completely obvious but I can only bang my head against the wall for so long. Any help/insight is greatly appreciated.
  댓글 수: 5
Fangjun Jiang
Fangjun Jiang 2011년 8월 29일
In earlier release, if you type help uitabel, you will see
This function is undocumented and will change in a future release
G
G 2011년 8월 29일
Thanks so much for your patience. I found the error buried in table construction. The text column was off by one. It was my indexing.
Cheers.

댓글을 달려면 로그인하십시오.

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 8월 29일
try datacellarray(event.Indices(1),event.Indices(2)) = {event.NewData};
  댓글 수: 9
G
G 2011년 8월 29일
It appears I can only use 'char' as a ColumnFormat.
"ColumnFormat definitions must be either 'numeric', 'logical', 'char', or be a popupmenu definition"
I am getting the feeling it is something deeper.
Fangjun Jiang
Fangjun Jiang 2011년 8월 29일
Run the two lines below and then try to change the value. In column 1, if you try to type in 'abc', it will become NaN. In column 2, you can type in anything.
a={1 'a' true};
h=uitable('data',a,'columnformat',{'numeric','char','logical'},'columneditable',true)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by