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

11 次查看(过去 30 天)
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?

采纳的回答

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 CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by