Compare elements within cell array
1 次查看(过去 30 天)
显示 更早的评论
Hi all
I have a cell array A
A={[1x4 cell];[1x3 cell];[1x5 cell]}
A{1,1}= {[1,-0.03,0.1,1.3,0,0.23,1,0,0.2],[1,0.6,0.1,2,0,0.6,0.6,0,0.6],[1,-0.15,0,1.4,0,0.35,1,0,0.3],[2,-0.2,0.1,3,0,0.4,0,0,0.4]}; similarly values for other A{2,1} and A{3,1}
I want to compare all elements of A with every other element. Like A{1,1}{1,1} with A{1,1}{1,2}, A{1,1}{1,3} and A{1,1}{1,4} and similarly A{1,1}{1,2} with all others to find which one is less. If every single element (col values) is less it means that row is less than other row. store index of that row in a separate array. and same for other elements of A.
Kindly help.
0 个评论
采纳的回答
KSSV
2017-12-28
YOu can get the minimum value of each cell using cellfun and min.
A{1,1}= {[1,-0.03,0.1,1.3,0,0.23,1,0,0.2],[1,0.6,0.1,2,0,0.6,0.6,0,0.6],[1,-0.15,0,1.4,0,0.35,1,0,0.3],[2,-0.2,0.1,3,0,0.4,0,0,0.4]};
cellfun(@min,A{1})
4 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!