首页 > 解决方案 > 如何使这些矩阵大小相同?

问题描述

我有 1x252 矩阵和 13x252 矩阵。我需要使它们匹配,以便我可以使用 corrcoef 找到相关系数。不完全确定如何使用该功能,并且我有一段时间没有做过很多matlab。

标签: matlabmatrixsizecorrelationcoefficients

解决方案


如果没有更多关于如何在矩阵中配置数据的详细信息,这就是我想出的。该脚本使用该repmat()函数重复/复制Matrix_1此示例中的行。

%Random data sets%
Matrix_1 = rand(1,252);
Matrix_2 = rand(13,252);

%Repeating the rows of x to match the number of rows in y%
Matrix_1 = repmat(Matrix_1,13,1);


Correlation_Coefficients = corrcoef(Matrix_1,Matrix_2);
Correlation_Coefficients

使用 MATLAB 版本:R2019b


推荐阅读