Searching through table using compound condition

조회 수: 1 (최근 30일)
Roger Breton
Roger Breton 2022년 3월 15일
답변: Roger Breton 2022년 3월 15일
I would leke to add a Munsell Notation readout capability to my script. Right now, when the student clicks a point in scatter3 graph, a custom data tip is used to report CIE Colorimetry :
This is great but I would like to add the corresponding Munsell Notation, somewhere in the figure. I tried to add it to my custom data tip function to no avail. So I accepted to display it, somewhere at the bottom right, through a text uicontrol in response to the "Plot2D" pushbutton uicontrol being pressed. Not ideal but it will work.
In order to do this, I'm using this code :
C = readcell('Munsell/1 - 2.5 BG_2.csv');
T = cell2table(C, "VariableNames",["Notation" "CIE_L" "CIE_a" "CIE_b"])
target = 51.71;
table2 = T(T.CIE_L == target,:);
You see, when the student selects a point in 3D space, it's possible that its CIE L* value would be unique in the file. But it's also possible that the value would not be unique, and in this case, my little search trick would be defeated? So I'm thinking, is there a way I could use a set of conditions in the selection statement above, such as :
C = readcell('Munsell/1 - 2.5 BG_2.csv');
T = cell2table(C, "VariableNames",["Notation" "CIE_L" "CIE_a" "CIE_b"])
target_L = 51.71;
target_a = -43.15;
target_b = -1.43;
table2 = T(T.CIE_L == target_L & T.CIE_a == target_a & T.CIE_b == target_b ,:);
Would this be acceptable? The search files are relatively small.

답변 (1개)

Roger Breton
Roger Breton 2022년 3월 15일
It worked! Sorry for the newbie question. I'm sure there are far more elegant ways to do search a table for information... Will see how far I can get on this code -- thank you for your kind attention.
I'm bound to have follow-up questions...


Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기





Community Treasure Hunt

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

Start Hunting!

Translated by