フィルターのクリア

How to return the smallest vector.

19 ビュー (過去 30 日間)
jg
jg 2020 年 1 月 17 日
コメント済み: Matt J 2020 年 1 月 17 日
If I have N vectors of different length how would i isolate and return the vector of the smallest length? I dont care what the length is i just need which is the smallest one.

採用された回答

Matt J
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
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
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 ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by