doing some orders in specific time in a loop

조회 수: 1 (최근 30일)
john white
john white 2021년 1월 29일
답변: john white 2021년 1월 30일
Hi
I'm using this code to do some orders in a for loop, I want to measure the time in the loop and if the passed time equals to a specific value do another order else wait until that specific time but the code do the for loop as soon as posible and never checked that time.could you help me please,
this is the code:
clear,clc
a = 5;
b = ones(2);
x = zeros(2);
t3 = zeros(1,5);
for i = 1:5
tic
c = a*b;
k = x-2*c;
x = k;
while toc == 0.5
k = k*3;
end
end

채택된 답변

john white
john white 2021년 1월 30일
hi every one I found the answer and I write that here maybe it be useful for others
clear,clc
a = 5;
b = ones(2);
x = zeros(2);
t3 = zeros(1,5);
for i = 1:5
tic
c = a*b;
k = x-2*c;
x = k;
s = 0.5-toc;
if sign(s)==1
pause(s)
else
pause(0)
end
k = k*3;
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by