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

45 vues (au cours des 30 derniers jours)
Poulomi Ganguli
Poulomi Ganguli le 15 Août 2017
Commenté : Ranjeet Singh le 3 Août 2022
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 commentaires
José-Luis
José-Luis le 15 Août 2017
And how would the "reducing" work?
Poulomi Ganguli
Poulomi Ganguli le 15 Août 2017
deleting the rest of element

Connectez-vous pour commenter.

Réponse acceptée

Ryan Klots
Ryan Klots le 15 Août 2017
Modifié(e) : Ryan Klots le 15 Août 2017
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);

Plus de réponses (1)

José-Luis
José-Luis le 15 Août 2017
Modifié(e) : José-Luis le 16 Août 2017
result = {A,B}
minDim = min(cellfun(@numel,result));
result = cellfun(@(x) {x(1:minDim)}, result);

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by