【发布时间】:2011-11-16 20:30:12
【问题描述】:
有没有一种好方法可以使用矩阵运算或其他任何方法来加速这个 matlab 代码块(尤其是n,可能很大)?我超过 1/4 的执行时间都在这个小代码块中。
% Get the bin indexes that we will place the network in
bins = [];
for n=low_freq:0.5:high_freq;
bins = [bins, (n-spec_start)/spec_bin_size+1];
end
测试代码:
spec_start=2400
spec_bin_size=0.5
low_freq = 2437
high_freq=2438
bins = [];
for n=low_freq:0.5:high_freq;
bins = [bins, (n-spec_start)/spec_bin_size+1];
end
bins % 75 76 77
bins = [];
bins = (low_freq:0.5:high_freq - spec_start)./spec_bin_size + 1;
bins % empty?
【问题讨论】:
标签: performance matlab optimization