How to trim two vectors of differing lengths

5 ビュー (過去 30 日間)
Todd Simon
Todd Simon 2016 年 8 月 18 日
コメント済み: Todd Simon 2016 年 8 月 18 日
If I have two vectors of varying lengths or rows, how do I trim the end of the larger vector so that both vectors are now of the same length? For example, if I have the below:
A = [0
1
2]
B = [0
1
2
3
4]
What I want is something like:
A = [0
1
2]
B = [0
1
2]
Thanks for the help in advance.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 8 月 18 日
n=min(numel(A),numel(B))
A=A(1:n)
B=B(1:n)
  1 件のコメント
Todd Simon
Todd Simon 2016 年 8 月 18 日
Awesome. Thanks for the quick reply Azzi! Super simple!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by