If the service time distribution, S, is exponentially distributed with rate lambda = 3, then the average service time is 1/3.
You'll see the Exponential distribution often parameterized by the rate lambda, but MATLAB uses the mean. You can see MATLAB's parameterization here in the documentation.
To generate service times, one can use exprnd
directly or use the inverse transform for the Exponential distribution.
N = 4000;
lambda = 3; % Rate Note: AvgSvcTime = 1 / lambda
SvcTimes = exprnd(1/lambda,N,1); % Approach 1
U = rand(N,1); % U ~ Uniform(0,1)
SvcTimes2 = -(1/lambda)*log(1-U); % Approach 2 with Inverse Transform

Note: You can replace 1-U
with U
since they are equal in distribution.