The data of the cells you want to edit need to be in the correct format.
There are two issues:
1)
data = D(:,1);
I understand you just want to use the data of the first column, but you need to declare the other columns as well, as locicals.
2)
Your data does not fit the columnformat
, so rather use:
D = {'1', false, false ,false, false, false; ...
'7', false, false, false, false, false};
Solution:
D = {'1', '2', '3' ,'4', '5','6' ;
'7', '8', '9', '10', '11' ,'12'};
data = [ D(:,1) num2cell( false( size(D,1) , size(D,2)-1) ) ];
%// where the -1 depends on how many "real" data columns you have.
or more generic:
N = 1; %// Number data columns to keep
data = [ D(:,1:N) num2cell( false( size(D,1) , size(D,2)-N) ) ];
All in all, the following code works, now you need to apply it to your case:
p = figure;
D = {'1', '2', '3' ,'4', '5','6' ;
'7', '8', '9', '10', '11' ,'12'};
data = [ D(:,1) num2cell( false( size(D,1) , size(D,2)-1) ) ];
cnames = {'', 'Left', 'Right','P1', 'P2', 'P3'};
table_resultat_nip=uitable('position',[0 200 500 200],...
'columnname', cnames,...
'rowname', '',...
'data',data,...
'ColumnFormat',{'char','logical','logical','logical','logical','logical'},...
'ColumnEditable',[false, true, true, true, true, true]...
);
Regarding the comment:
Okay, an even more generic case:
N = 1; %// Number data columns to keep
M = 5; %// Number of checkboxes desired
data = [ D(:,1:N) num2cell( false( size(D,1) , M) ) ];