flatten.m

来自「fading 在无线中的应用」· M 代码 · 共 25 行

M
25
字号
function res = flatten(m, dim)  % DESCRIPTION res = flatten(m, dim)%  Align all elements of m along dimension dim.%  The elements are taken columnwise from m.%  If dim is not present along rows is assumed.%  m can be any matrix and dim can be any %  scalar integer from 1 and up.% INPUT %  m --    any matrix %  dim --  any integer greater than 0% OUTPUT%  res --  A matrix only spanning dimesion dim.% TRY%  flatten([1 2; 3 4],3) % by Magnus Almgren 970527if nargin > 1   % Note the extra 1 at the end, since reshape needs   % a dimension vector of at least 2 element.  res = reshape(m,[ones(1, dim-1), prod(size(m)) 1]);else  res = m(:); % in the old matlab4 styleend

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?