How to determine if a non-integer value is between two non-integer values?

My goal has been to determine how long a queue is when I have the current time in the system and an array full of arrival times. My code looks like this:
for k=served1:(A1)
if (queue1(1,k)<=timetracker)
queue1counter=queue1counter+1;
end
end
Where A1=the number of total customers, timetracker= the current time, and queue1(1,:)=the arrival times of customers.
My problem is the amount of time I must run this simulation and how many times this loop runs. My computer can't handle it and it's been crashing. So I've been trying to come up with a better way to write it.
The part that isn't working for me is when I try to determine if a non-integer value from queue1(1,:) is between timetracker and previoustimetracker, where timetracker-previoustimetracker=eventtime. Here is my code so far:
test=(timetracker-eventtime):0.0001:timetracker;
for a=1:length(test)
if test(a)>queue1(1,check1)
queue1counter=queue1counter+1;
check1=check1+1;
end
end
For some reason, when I have two values that are close to each other in queue1(1,:), the queue1counter fails to update a second time. For example, this has happened when queue1(1,x)=16.4198 and queueu1(1,x+1)=16.4838.
To me, this doesn't make sense. I would think it should count it because I'm incrementing my counter/checker by 0.0001 and queue1(1,x+1)-queue1(1,x)>0.0001.
Why is this happening? Is there any easier way to find a non-integer value between two non-integer values? And not only determine if there is a value between the points but determine how many?
Thanks in advance.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Preguntada:

el 24 de Abr. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by