필터 지우기
필터 지우기

ColumnEditable problem with categorical

조회 수: 5 (최근 30일)
piero
piero 2023년 6월 16일
댓글: piero 2023년 6월 16일
f = figure('Position', [100 100 752 250]);
t = uitable('Parent', f, 'Position', [25 50 700 200]);
t.ColumnName = {'Num1','Num2','Text'};
t.Data = {'b', 'q','JN'};
t.ColumnEditable=[true,true,true];
ret=categorical({'H';'L'});
t.ColumnFormat ={'bank' ret 'bank'};
Error setting property 'ColumnFormat' of class 'Table':
ColumnFormat definitions must be either 'numeric', 'logical', 'char', or be a popupmenu definition
Error in CANCELLA (line 10)
t.ColumnFormat ={'bank' ret 'bank'};

채택된 답변

Cris LaPierre
Cris LaPierre 2023년 6월 16일
You can't set the ColumnFormat value to be a categorical. It must be either 'numeric', 'logical', 'char', or be a popupmenu definition (character array).
Why not just do this?
f = figure('Position', [100 100 752 250]);
t = uitable('Parent', f, 'Position', [25 50 700 200]);
t.ColumnName = {'Num1','Num2','Text'};
t.Data = {'b', 'q','JN'};
t.ColumnEditable=[true,true,true];
ret={'H' 'L'};
t.ColumnFormat ={'bank' ret 'bank'};
Not sure what you want the 'bank' values to be. If you meant 'blank', use [] instead.
t.ColumnFormat ={[] ret []};
If you meant to have them be dropdown menu uptions for the first and third column, do this.
t.ColumnFormat ={{'bank'} ret {'bank'}};
  댓글 수: 5
Cris LaPierre
Cris LaPierre 2023년 6월 16일
Again, you can't use categoricals. It must be a char. If your data coming in is categorical, you must extract the categories and use that to set the ColumnFormat.
May something like this?
f = figure('Position', [100 100 752 250]);
t = uitable('Parent', f, 'Position', [25 50 700 200]);
t.ColumnName = {'Num1','Num2','Text'};
t.Data = {'b', 'q','JN'};
t.ColumnEditable=[true,true,true];
ret=categorical({'H';'L'});
cat = categories(ret);
t.ColumnFormat ={[] {cat{:}} []};
piero
piero 2023년 6월 16일
thanks..correct

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Continuous Wavelet Transforms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by