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

조회 수: 4(최근 30일)
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;
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')

채택된 답변

Yongjian Feng
Yongjian Feng 2021년 8월 3일
Why not a drop down selection of three values?
  댓글 수: 7
DulceEien 2021년 8월 3일
@Yongjian Feng thank you so much again, it is working

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

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by