How can I get the column number of a matrix with smallest error to my value?

조회 수: 2 (최근 30일)
Lukas Nuschele
Lukas Nuschele 2020년 1월 12일
답변: Stijn Haenen 2020년 1월 12일
Hey,
The code below finds values("Tempvalue") out of a predefined RGB Scale ("RGB"), output "x" shall be the number of the row this value occurs.
How can I find the value of a Matrix "Tempvalue=100x3" within a "RGB=875x3" Matrix with the smallest error if an exact value doesn´t exist in this matrix?
Output x should be the column number of RGB where the value with the smallest error occurs.
Thanks for you help, if any questions feel free to ask :)
Greetings Lukas
x=0;
for i=1:100
Tempvalue=RGBTemp(i,:);
x=find(ismember(RGB,Tempvalue,'rows'));%will give you the column numbers of RGB that match Tempvalue
if x~=0
break;
end
else % x should be the column number of RGB with smallest error to Tempvalue
end

답변 (1개)

Stijn Haenen
Stijn Haenen 2020년 1월 12일
Mybe you can use:
[x,y,z]=find(....)

카테고리

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