Matlab:代码的有效部分,随机启动

Matlab:代码的有效部分,随机启动,matlab,Matlab,我有下面的代码,它生成了一个由15个块组成的矩阵,然后将在Montecarlo方法中用作多个起点。如何以更智能的方式获得相同的精确结果 假设J=15*100为总模拟,paramNum为参数数 [10^-10*ones(paramNum,round(J/15)) 10^-9*ones(paramNum,round(J/15)) 10^-8*ones(paramNum,round(J/15)) 10^-7*ones(paramNum,round(J/15)) 10^-6*ones(paramNum,

我有下面的代码,它生成了一个由15个块组成的矩阵,然后将在Montecarlo方法中用作多个起点。如何以更智能的方式获得相同的精确结果

假设J=15*100为总模拟,paramNum为参数数

[10^-10*ones(paramNum,round(J/15)) 10^-9*ones(paramNum,round(J/15)) 10^-8*ones(paramNum,round(J/15)) 10^-7*ones(paramNum,round(J/15)) 10^-6*ones(paramNum,round(J/15)) 10^-5*ones(paramNum,round(J/15)) rand*10^-5*ones(paramNum,round(J/15)) 10^-4*ones(paramNum,round(J/15)) rand*10^-4*ones(paramNum,round(J/15)) 10^-3*ones(paramNum,round(J/15)) 10^-2*ones(paramNum,round(J/15)) 10^-1*ones(paramNum,round(J/15)) 10^-abs(randn/2)*ones(paramNum,round(J/15))];
你可以

v = 10.^[-10:-5 rand*10^-5 -4:-1 10^-abs(randn/2)];
repmat(repelem(v, 1, round(J/15)), paramNum) .* ... 
repmat(ones(paramNum,round(J/15)), numel(v))
或者使用for循环模拟repmat/repelem功能。前者较短,后者更容易理解

顺便说一下。。。不到15个街区