Is there a good way to speed up this block of matlab code (n in particular, can be large) using matrix operations, or anything? Over 1/4 of my execution time is in this small block of code.
% 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
Test code:
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?