# MATLAB time delay

#### ircommando

Joined Jun 17, 2009
3
I am writing a simple program that repeats itself forever until the user stops it. It samples a waveform from an oscope and when one of the waveforms meets a certain criteria it stops the scope, saves the waveforms on all four channels, starts the scope back up, and starts over again. My question is how can I delay the repeated sampling of the "trigger" waveform.The wavefrom does not change that quickly so if I could sample it every 5-10 seconds that would save my computer from incessantly computing the trigger condition. The test could run for well over a day so giving the computer a break is probably a good thing. I bet there is a very simple solution to this, but I am a noobie to programming, and am still learning a lot of the basic tricks so any help is greatly appreciated. Thanks.

#### ryta

Joined Aug 27, 2009
4
hi buddy you can do this by applying loop condition in it and just insert a condition such that which can execute your loop infinitely until that condition is satisfied.

Last edited by a moderator:

#### prionkor

Joined Jun 8, 2009
7
You can try by infinite loop. Use while or for loop. Most commonly used loop for infinite loop is while. Here is a simple program which has a infinite while loop defined by while(1):

i=0;
while(1)
i
if i==1000
break
end
i = i+1;
end

if statement is very important in infinite loop where in certain you have to break the loop. Otherwise the loop will never stops. I this case you will able to break the loop by pressing ctrl+c in PC or cmd+c in mac.

Thanks.

#### kaankarabulut

Joined Oct 3, 2009
3
you may be use 'clock' function. this function is return that your computer's time
c = clock
c = [year month day hour minute seconds]

c =
1.0e+003 *
2.0090 0.0100 0.0040 0.0020 0.0110 0.0485