📄 rep.m
字号:
% REP.m Replicate a matrix%% This function replicates a matrix in both dimensions. %% Syntax: MatOut = rep(MatIn,REPN);%% Input parameters:% MatIn - Input Matrix (before replicating)%% REPN - Vector of 2 numbers, how many replications in each dimension% REPN(1): replicate vertically% REPN(2): replicate horizontally%% Example:%% MatIn = [1 2 3]% REPN = [1 2]: MatOut = [1 2 3 1 2 3]% REPN = [2 1]: MatOut = [1 2 3;% 1 2 3]% REPN = [3 2]: MatOut = [1 2 3 1 2 3;% 1 2 3 1 2 3;% 1 2 3 1 2 3]%% Output parameter:% MatOut - Output Matrix (after replicating)%% Author: Carlos Fonseca & Hartmut Pohlheim% History: 14.02.94 file createdfunction MatOut = rep(MatIn,REPN)% Get size of input matrix [N_D,N_L] = size(MatIn);% Calculate Ind_D = rem(0:REPN(1)*N_D-1,N_D) + 1; Ind_L = rem(0:REPN(2)*N_L-1,N_L) + 1;% Create output matrix MatOut = MatIn(Ind_D,Ind_L);% End of function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -