I want to ask a very noob question: My elseif condition is never checked. What to do?
Why do I ask this?
So, let me explain.
I got this piece of code:
A = [0.4 1.2 0.5 0.7 0.2 0.6];
S = [2.0 0.7 0.2 1.1 3.7 0.6];
in(1) = 0.4;
out(1) = in(1)+S(1);
list = 0;
for i = 2:6
in(i) = in(i-1)+A(i);
for j = 2:6
out(i) = max(out(i-1),out(i))+S(i);
So, this program simulates the inputs and outputs in/from a server
Inputs(in) and outputs(out) are already calculated in above for
The idea is simple: if an input is done in server, list will increment by 1, if an output is done from server it will decrement by 1
A way to do this is to compare if, on time axe, we have inputs in server or outputs from it and to increment and decrement accordingly
Here everything I think looks clear for me, I know how to make those ifs
But the big challenge for me is to see the evolution of the list on a plot
So, I wrote this piece of code
i = 1;
o = 1;
n = 1;
for r = 0:0.1:12
if r == in(i)
list = list + 1;
i = i + 1;
elseif r == out(o)
list = list - 1;
o = o + 1;
n = n + 1;
My plot looks like this:
Which is I intended, but it looks like the graph will never decrement, it will not go in elseif part.
What can I do in order to make my plot to go down ( to check that elseif as well ) in order to make it work on my plot?
List stores how many clients are not in server ( because one client is in there )
Time stores how much time did server had to take for each client
If I am unclear in what I am asking for, you can ask me to clear some things up.
Thank you for any kind of help.