Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am still getting the error message: ndex exceeds the number of array elements. Index must not exceed 6 % Run this test case to

I am still getting the error message: ndex exceeds the number of array elements. Index must not exceed 6% Run this test case to check your code
c =2; % Number of servers
lambda =2; % Average Arrival Rate per minute
mu =0.1; % Service rate
Nwait =15;
% Call the MMCQ function with the given parameters
%[Ws, Wq, c_util, p_drop, p_state]= MMCQ(lambda, mu, c, Nwait);
[Ws, Wq, c_util, p_drop, p_state]= MMCQ(1,0.5,4,5);
% Define a relative error function
rel_error = @(x, y) abs(x - y)/ y;
% Validate the results and print "PASS" or "FAIL" for each metric
if rel_error(Ws,2.1557)<0.005
fprintf('Ws =%6.3f PASS
', Ws);
else
fprintf('Ws =%6.3f FAIL
', Ws);
end
if rel_error(Wq,0.1557)<0.005
fprintf('Wq =%6.3f PASS
', Wq);
else
fprintf('Wq =%6.3f FAIL
', Wq);
end
if rel_error(c_util, 0.4986)<0.005
fprintf('c_util =%6.3f PASS
', c_util);
else
fprintf('c_util =%6.3f FAIL
', c_util);
end
if rel_error(p_drop, 0.00272)<0.005
fprintf('p_drop =%8.5f PASS
', p_drop);
else
fprintf('p_drop =%8.5f FAIL
', p_drop);
end
fprintf('p_state: %s
', num2str(p_state));
fprintf('sum(p_state): %f
', sum(p_state));
% Extra Tests: p_state
% p_state should have Nwait+1 probabilities
% disp(['The probability of being in state ', num2str(Nwait),' is ', num2str(p_state(Nwait +1))]);
disp(['The probability of being in state ',' is ', num2str(p_state)]);
% Check that the probabilities sum to 1
% Assuming 10 states
num_states =15
if abs(sum(p_state)-1)<1e-5
disp('The probabilities sum to 1. Test PASSED.');
else
disp('The probabilities do not sum to 1. Test FAILED.');
end
% Corrected p_state initialization
p_state =[-0.010609,-0.021217,-0.021217,-0.014145,-0.0070725,-0.05658,0.0,0.0,0.0,0.0]
% Check if the sum of probabilities is close to 1
if sum(p_state)!=1
disp("Warning: Probabilities do not sum to 1.")
end
% Assuming 10 states
num_states =15
% Print the results
fprintf('Ws: %6.3f
', Ws);
fprintf('Wq: %6.3f
', Wq);
fprintf('c_util: %6.3f
', c_util);
fprintf('p_drop: %8.5f
', p_drop);
fprintf('
State Probabilities:
');
for i =0:Nwait
fprintf('p_state(%d): %f
', i, p_state(i +1));
end
fprintf('
The probabilities sum to 1. Test PASSED.
');

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

Discuss how S. Truett Cathys values shaped Chick-fil-As operation.

Answered: 1 week ago