Repeating timer doesn't work
Show older comments
Hello,
I'd like to ask you for help.
I'm currently preparing simple application for an instrument which I use in the lab.
Basicaly you input values in through some form and the instrument sets (changes) voltage to the value you input and keeps it for the time you input.
I tried to use for loop in this case, at first you create an matrix of inputs for example Ut = (3x2) matrix.
Now I created a for loop which I expected to execute operations in function zobraz after some time in this case three times. for cnt = 1:ValCnt t = timer; t.StartDelay = Ut(cnt,2); t.TimerFcn = {@zobraz, Ut}; start(t); end
Basicaly if Ut = (1 10; 5 18; 3 14), I'd like to run the application with value 1 for ten seconds then change the value from 1 to 5 and run the application for 18 seconds and then change the value from 5 to 3 and run the application for 14 seconds. But when I use the code above it executes first operation after some random time, second operation goes off immediately after the first one and the third one is executed after some time, but basicaly times are not similar to my input.
I hope its understandable and that you can help me with this problem, I'm getting pretty frustated over this thing and I would really appreciate your help.
Thank you very much.
2 Comments
per isakson
on 4 Jul 2013
Markup makes it easier to read the code. Use the {}Code button
for cnt = 1:ValCnt
t = timer;
t.StartDelay = Ut(cnt,2);
t.TimerFcn = {@zobraz, Ut};
start(t);
end
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!