Skip to content

Instantly share code, notes, and snippets.

@nikAizuddin
Created October 9, 2014 01:57
Show Gist options
  • Save nikAizuddin/e38fe5bb3c5b237609eb to your computer and use it in GitHub Desktop.
Save nikAizuddin/e38fe5bb3c5b237609eb to your computer and use it in GitHub Desktop.
function [T] = test()
%Arrival Time
A = [ 2.17, 7.90, 15.00, 15.17, 15.73,...
18.74, 19.86, 22.51, 23.70, 31.06];
%Begin service
W = [0 0 0 0 0 0 0 0 0 0];
%Service Time
S = [0.10, 4.46, 3.25, 2.26, 4.12, 0.69, 0.77, 3.48, 0.26, 0.41];
%Departure time
D = [0 0 0 0 0 0 0 0 0 0];
%Time in Queue
Q = [0 0 0 0 0 0 0 0 0 0];
%Time in System
P = [0 0 0 0 0 0 0 0 0 0];
%Formula begins here
W(1) = A(1);
D(1) = W(1) + S(1);
Q(1) = W(1) - A(1);
P(1) = D(1) - A(1);
for i=2:1:10
if ( A(i) > D(i-1) )
W(i) = A(i);
else
W(i) = D(i-1);
end
D(i) = W(i) + S(i);
Q(i) = W(i) - A(i);
P(i) = D(i) - A(i);
end
%Formula ends here
%Create table
T = table([1;2;3;4;5;6;7;8;9;10],...
[W(1);W(2);W(3);W(4);W(5);...
W(6);W(7);W(8);W(9);W(10)],...
[S(1);S(2);S(3);S(4);S(5);...
S(6);S(7);S(8);S(9);S(10)],...
[D(1);D(2);D(3);D(4);D(5);...
D(6);D(7);D(8);D(9);D(10)],...
[Q(1);Q(2);Q(3);Q(4);Q(5);...
Q(6);Q(7);Q(8);Q(9);Q(10)],...
[P(1);P(2);P(3);P(4);P(5);...
P(6);P(7);P(8);P(9);P(10)],...
'VariableNames',...
{'Customer' 'BeginService' 'TimeService' ...
'DepartureTime' 'TimeInQueue' 'TimeInSystem'});
%Create bar graph
Y = [W;S;D;Q;P]';
bar(Y);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment