Make two matrices of same length reducing the size of largest matrix

46 ビュー (過去 30 日間)
Poulomi Ganguli
Poulomi Ganguli 2017 年 8 月 15 日
コメント済み: Ranjeet Singh 2022 年 8 月 3 日
Hello, I have two matrix, A = [318x1] and B = [313x1]. In order to compare between two, I need to make size of A same as that of B, by reducing the size of A. Any help?
  2 件のコメント
José-Luis
José-Luis 2017 年 8 月 15 日
And how would the "reducing" work?
Poulomi Ganguli
Poulomi Ganguli 2017 年 8 月 15 日
deleting the rest of element

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

採用された回答

Ryan Klots
Ryan Klots 2017 年 8 月 15 日
編集済み: Ryan Klots 2017 年 8 月 15 日
You could try something like
% Find out the length of the shorter matrix
minLength = min(length(A), length(B));
% Removes any extra elements from the longer matrix
A = A(1:minLength);
B = B(1:minLength);

その他の回答 (1 件)

José-Luis
José-Luis 2017 年 8 月 15 日
編集済み: José-Luis 2017 年 8 月 16 日
result = {A,B}
minDim = min(cellfun(@numel,result));
result = cellfun(@(x) {x(1:minDim)}, result);

カテゴリ

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