Return value from a UITABLE
Ältere Kommentare anzeigen
Hi All,
Does anyone know if there is a way to search for a specific value in a UI Table and return the value in the column next to it?
I am using a GUI and the user selects a value from a lsitbox and I would like to look for that selected value in the 3 column UITABLE that is in the GUI (that already has data in it) and return the value in the column next to it.
They value being searched for is always in column 1 of the UITABLE (if that helps at all).
Any help is appreciated!!
Rob
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 14 Feb. 2013
Get the table data:
tableData = get(handles.table1, 'Data');
You might have to use cell2mat(tableData) - I don't remember. Then use extract the column you're looking for and use ismember() or find() to find the matching value. Be sure to know the FAQ. So you might want to do
theColumn = tableData(:, 1); % Get column 1
row = find(abs(theColumn - theSoughtValue) < 0.00001);
Then just get the next column.
theValueWeWant = table(row, 2);
1 Kommentar
mtr
am 18 Feb. 2013
Kategorien
Mehr zu Programming finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!