www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/CloneSizeFromExistingArrayrandExample.m

    %% Clone Size from Existing Array  

%% 
% Create a matrix of random numbers with the same size as an existing array. 
A = [3 2; -2 1];
sz = size(A);
X = rand(sz)  

%% 
% It is a common pattern to combine the previous two lines of code into
% a single line: 
X = rand(size(A));