MATLAB: How to find the maximum of mu by solving eqn

empty solutionsolution is not uniquesolve

Hi, Can anyone please help me how to do this? Find the maximum of mu by solving eqn. Thank you so much.
sigma = 1;
syms mu
n = 5;
lambda = 1;
U = normrnd(0,1,n,1);
V = normrnd(0,1,n,1);
W = (lambda/sqrt(1+lambda^2))*abs(U) + (1/sqrt(1+lambda^2))*V
W_bar = sum(W)/n
eqn = (W_bar - mu)/sigma == lambda*sum(normpdf(lambda*(W-mu)/sigma)/normcdf(lambda*(W-mu)/sigma));
sol = solve(eqn,mu)

Best Answer

I think you are after
eqn = ((W_bar - mu)/sigma) - lambda*sum(normpdf(lambda*(W-mu)/sigma)./normcdf(lambda*(W-mu)/sigma))
rather than
eqn = ((W_bar - mu)/sigma) - lambda*sum(normpdf(lambda*(W-mu)/sigma)/normcdf(lambda*(W-mu)/sigma));
and then solve(eqn==0,mu). Note that the first equation returns a unique value while the second is actually a vector.
Does that make sense?