How to validate user input in a UITable between three values?

조회 수: 6 (최근 30일)
DulceEien
DulceEien 2021년 8월 3일
댓글: DulceEien 2021년 8월 3일
I just one the user gives numbers either 0.5, 0.7 or 1
function damage
% Create table array
t = readtable('Country.xls');
vars = {'Damage','G','k1','k2','k3','k4'};
t = t(1:32,vars);
% Create UI figure
fig = uifigure;
% Create table UI component
uit = uitable(fig);
uit.Data = t;
% uit.ColumnSortable = true;
uit.ColumnEditable = [false false true true true true];
uit.CellEditCallback = @k1CheckCB;
end
I did another function like this, but I'm not sure how it is supossed to work with a triple conditional
function k1CheckCB(t)
if (t.k1 == 0.5 || t.k1 == 0.7 || t.k1 == 1.0)
tableData = uit.Data;
tableData{t.k1} = t.PreviousData;
uit.Data = tableData;
warning('Extent values are only 0.5, 0.7 and 1.0')
end
end

채택된 답변

Yongjian Feng
Yongjian Feng 2021년 8월 3일
Why not a drop down selection of three values?
  댓글 수: 7
DulceEien
DulceEien 2021년 8월 3일
편집: DulceEien 2021년 8월 3일
I understand, it is because I wanted to limit only to those values for that k1 column (values either 0.5, 0.7 or 1), but I saw that ~ismember for a row values, before as you mentioned I wanted to assign a drop down bottom but I got also a mistake
something like this:
extent = categorical(t.k1,{'0.5','0.7','1.0'});
t.k1 = extent;
DulceEien
DulceEien 2021년 8월 3일
@Yongjian Feng thank you so much again, it is working

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

추가 답변 (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