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

10 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

Ryan Klots
Ryan Klots el 15 de Ag. de 2017
Editada: Ryan Klots el 15 de Ag. de 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);

Más respuestas (1)

José-Luis
José-Luis el 15 de Ag. de 2017
Editada: José-Luis el 16 de Ag. de 2017
result = {A,B}
minDim = min(cellfun(@numel,result));
result = cellfun(@(x) {x(1:minDim)}, result);

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by