Just wondring why my code is returning NaN when I use the mean fucntion? My numbers are not that big i have scaled back the number of runs from 1000 to 10 but still no change. I'm confused
clear all
close all
clc
% set up variables
no_of_calls = 60;
no_of_runs = 10;
CallTime = [];
CallLength =[];
n = ones(1,no_of_calls).*42;
E_1 = zeros(no_of_runs, no_of_calls);
call_timeDIST= makedist('Uniform');
call_lengthDIST = makedist('Poisson','lambda',3);
CallLength = zeros(no_of_runs,no_of_calls);
for i = 1:no_of_calls
for j = 1:no_of_runs
% Create distribution for calls in time
CallTime(j) = random(call_timeDIST);
% Create distribution for call length
CallLength(j,i) = random(call_lengthDIST);
% calculate A0
A_0 = 600.*(CallLength./60);
% calculate E_1 using Erlings-B Formula
E_1(j,i) = part_2(A_0(j,i), n(i));
end
% Find Mean for number of iterations
GOS = mean(E_1,2);
end
Unrecognized function or variable 'part_2'.
CT = sort(CallTime)';
plot(CT, GOS)

댓글 수: 2

Torsten
Torsten 2022년 10월 17일
We don't know what "part_2" does with A_0(j,i) and n(i).
Cormac Carr
Cormac Carr 2022년 10월 17일
function E_1 = part_2(A_0,n)
for i = 1:n
S(i) = (A_0^i)/factorial(i); %% Create vector of
% values to be summed
% to create denominator
dnom = cumsum(S); %% Create denominator
end
for n = 1:n
num1(n) = ((A_0^n)/factorial(n)); %% loop through values
% values of n for numerator
% createing vector of numerators
% for specified A0
end
for n = 1:n
E_1 = num1(n)./dnom(n); % Complete formula for answer
end

댓글을 달려면 로그인하십시오.

 채택된 답변

David Hill
David Hill 2022년 10월 17일

0 개 추천

function E_1 = part_2(A_0,n)
n=1:n;
S = (A_0.^n)./factorial(n);
dnom = cumsum(S);
E_1 = S./dnom;
end

댓글 수: 2

Cormac Carr
Cormac Carr 2022년 10월 17일
Unable to perform assignment because the size of the left side is 1-by-1 and the
size of the right side is 1-by-42.
Error in EE4101_Cormac_Carr_Part2 (line 26)
E_1(j,i) = matlab(A_0(j,i), n(i));
Cormac Carr
Cormac Carr 2022년 10월 17일
Got it working thanks for your help

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2022년 10월 17일

댓글:

2022년 10월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by