MATLAB: Efficiency help

efficiency

hi, i need some help in improving this section of code. it takes over 20 seconds to run. Because i have over 150 samples to run, a 10 second improvement would mean close to 1 hour of time saved. Thanks!
for p = 1: length(unique_cell(1,:)) for f = 1:length(ions{1,p})
max_inloop(f)= (ions{2,p}(1,f))/(ions{1,p}(1,f));
max_inloop2(f)= (ions{1,p}(1,f))/(ions{2,p}(1,f));
end
max_ion_list{p} = max_inloop;
max_ion_list2{p} = max_inloop2;
end

Best Answer

for p = 1 : length(unique_cell(1,:))
max_inloop = ions{2,p}(1,:) ./ ions{1,p}(1,:);
max_ion_list{p} = max_inloop;
max_ion_list2{p} = 1 ./ max_inloop;
end
Related Question