Info

This question is closed. Reopen it to edit or answer.

how to optimize my for loops

1 view (last 30 days)
sam
sam on 15 Nov 2013
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi, JIT accelerator is not working for me, and currently, this piece of code looks like it's going to take about 3 hours...
My professor wrote a similar piece of code with the same usage and it completed within a few minutes... I'm really quite confused.
wav1 and wav2 are both 1x2601900 double.
basically, wav1 is a marker file for wav2, so I know where to cut and add to tmp.
function tmp = AddWaveform(Wav1,Wav2)
tmp=zeros(1,2090);
for i=1:1244
x=1;
flag=0;
while(flag==0)
if( mod(Wav2((i-1)*2090+x),7500)==0 )
tmp = tmp + Wav1((i-1)*2090+x : (i-1)*2090+x+2089);
flag=1;
end
x=x+1;
end
end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!