正确的matlab多维按行取reshape的方法

mac2024-07-09  58

正确的matlab多维按行取reshape的方法*

代码及说明

function a=res(A,a,b) %按行reshape a=reshape(A.',b,a).';

A为m×n大小的矩阵,欲按行reshape为a×b大小的矩阵,由于matlab里reshape函数是按列进行reshape,所以我们将A进行转置后,对应行变为列,后按b×a进行reshape,最后取转置返回正确答案;

最新回复(0)