I'm quite new at matlab, so I'm probably using a way to difficult solution for my problem.
I'm trying to have my code do two things at the same time. Currently it is increasing 1 value 1 till 400 and another till 2000. And I want to do this in one second. So value2 has to increase faster than value1.
However value 2 never reaches 2000. And the code is not fast enough.
Is it feasible to do what I want to do? And so yes, what am I doing wrong?
Thank in advance
The code I'm using for this is:
previousMillis1 = clock;
Rate1 = 400;
interval1 = 1/Rate1;
Rate2 = 2000;
interval2 = 1/Rate2;
value1 = 0;
value2 = 0;
currentMillis = clock;
if ((currentMillis(6)- previousMillis1(6)) >= interval1)
value1 = value1 + 1
previousMillis1(6) = currentMillis(6);
if ((currentMillis(6) - previousMillis2(6)) >= interval2)
value2 = value2 + 1
previousMillis2(6) = currentMillis(6);