How to return the smallest vector.
11 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Matt J
2020-1-17
编辑:Matt J
2020-1-17
If you "have them" in cell array form, then you could do something like this:
>> vectors={[3 4 5],[1,2],[5 6 7 8]}
vectors =
1×3 cell array
{1×3 double} {1×2 double} {1×4 double}
>> [~,imin]=min(cellfun('length',vectors));
>> smallest=vectors{imin}
smallest =
1 2
3 个评论
Image Analyst
2020-1-17
Well, what form were they in? Just separate variables? If so, you need to check their lengths one at a time.
Matt J
2020-1-17
Or, you will have to load them into a cell array manually,
vectors={v1,v2,v3,...}
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!