Matlab加速或用find函数摆脱循环

时间:2018-06-18 10:44:56

标签: matlab performance for-loop

只是努力寻找另一种实现方式来摆脱这种for循环。有没有办法摆脱缓慢的for-loop?谢谢你的帮助!

list = randi(2000,[2000 1]);
val = randi(2000,[2000 3000]);

for ii = 1:length(list)
    [y,x] = find( val  == list(ii) );
    minx = min(x);
    maxx = max(x);

    minx1 = ceil(minx + 0.05 * (maxx - minx ));
    maxx2 = ceil(maxx - 0.02 * (maxx - minx ));
    val(y,minx:minx1) = 0;
    val(y,maxx2:maxx) = 0;
end

0 个答案:

没有答案