Compare output with each row and column from a table.
1 次查看(过去 30 天)
显示 更早的评论
I have a table consisting of 28 rows and 8 columns. I want to check whether my output matched with any value from my table. The following code gives me correct output but in this case I have to specify row and column. But I needed a code which check automatically, so I can use same code on various images.
Can anyone help me?
if(minR == health{1,3})
if (maxR == health{1,6})
if(minG == health{1,4})
if (maxG == health{1,7})
if(minB == health{1,5})
if (maxB == health{1,8})
figure; imshow(A); title('HEALTHY')
end
end
end
end
end
else
figure; imshow(A); title('INFECTED')
end
0 个评论
回答(1 个)
Erivelton Gualter
2019-5-6
You might create a function to perform this task, an dyou call it as many times you desire.
% function return status
function out = getStatus(A, minR, maxR, minG, maxG, minB, maxB, health)
out = [];
if(minR == health{1,3})
if (maxR == health{1,6})
if(minG == health{1,4})
if (maxG == health{1,7})
if(minB == health{1,5})
if (maxB == health{1,8})
figure; imshow(A); title('HEALTHY')
out = 1;
end
end
end
end
end
else
figure; imshow(A); title('INFECTED')
out = 0;
end
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!