cell, , , . , :
generatorMatrix = {1 -1; 2 @randn};
, , , , :
function numMatrix = create_matrix(generatorMatrix)
index = cellfun(@(c) isa(c,'function_handle'),... %# Find function handles
generatorMatrix);
generatorMatrix(index) = cellfun(@feval,... %
generatorMatrix(index),...
'UniformOutput',false);
numMatrix = cell2mat(generatorMatrix); %
end
, , , . , , 5, 9, 9 1, 9 , 5 10:
generatorMatrix = {5 ones(1,9); ones(9,1) @() 5*rand(9)+5};
, create_matrix, 10--10 , 9--9 .
...
( ), .
, , , , , user57368, . : (, NaN), , , , , , . , .
3 3 3 , 2, 4 9, , 5 10 :
matData = struct('numMatrix',[1 nan 3; nan 2 4; 0 5 nan],...
'randIndex',[2 4 9],...
'randFcns',{{@randn , @() 5*rand+5 , @() -log(rand)/2}});
create_matrix, :
function numMatrix = create_matrix(matData)
numMatrix = matData.numMatrix;
numMatrix(matData.randIndex) = cellfun(@feval,matData.randFcns);
end