-
February 9th, 2010, 12:26 PM
#1
nested for loops
In Matlab I'm trying to find the nearest value of time1 to each value of time2 without going over the specific value of time2.
Is there a way to speed this up? It's very slow.
Here is my current code:
time1 = 0:1/44100:1-1/44100;
time2 = 0:1/48000:1-1/48000;
n1(1:size(time2,2)) = 0; %initialize n1 to be the size of the time2 variable
for i = 1:size(time2,2)
for j = 1:size(time1,2)
if time1(j)<=time2(i)
n1(i) = j;
end
end
end
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|