⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vrep.m

📁 JLAB is a set of Matlab functions I have written or co-written over the past fifteen years for the p
💻 M
字号:
function[varargout]=vrep(varargin)%VREP  Replicates an array along a specified dimension.%%   Y=VREP(X,N,DIM) replicates the (1-D) array by N times along %   dimension DIM.  For instance:   %                                                                         %        VREP([1:4]',3,2)=[ [1:4]' [1:4]' [1:4]' ]                            %                                                                         %   This is often useful in array algebra.                                %                                                                         %   See also VINDEX, DIM.      %   __________________________________________________________________%   This is part of JLAB --- type 'help jlab' for more information%   (C) 2001--2006 J.M. Lilly --- type 'help jlab_license' for details    if strcmp(varargin{1}, '--t')  vrep_test,returnendn=varargin{end-1};ndim=varargin{end};for i=1:length(varargin)-2  varargout{i}=vrep1(varargin{i},n,ndim);endeval(to_overwrite(nargin-2)) %You would think Matlab would provide a simpler way to do this.function[y]=vrep1(x,n,dim)  str=['y=repmat(x,['];ndx=ndims(x);for i=1:max(ndx,dim)    if i~=dim        str=[str '1,'];    else	str=[str 'n,'];    endendstr=[str(1:end-1) ']);'];eval(str);function[]=vrep_testans1=vrep([1:4]',3,2);ans2=[ [1:4]' [1:4]' [1:4]' ];reporttest('VREP', aresame(ans1,ans2))x1=[1:4]';x2=[1:4]';vrep(x1,x2,3,2);reporttest('VREP output redirect', aresame(x1,ans1) && aresame(x2,ans2))

⌨️ 快捷键说明

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