I am new to mathematica and having trouble understanding the syntax.
The code:
findMax[{b_, w_}, v_] := Min[Select[Join[Table[If[v[[i]] != 0, \[Lambda] /.Solve[(b + w*(0.5 + \[Lambda]*v))[[i]] == 0, \[Lambda]][[1]], -1], {i, 3}],
Table[If[v[[i]] != 0, \[Lambda] /.Solve[(b + w*(0.5 + \[Lambda]*v))[[i]] == 1, \[Lambda]][[1]], -1], {i, 3}]], # > 0 &]]
My corresponding matlab code is:
for i=1:3
if(v(i)~=0)
a=(-b/w);
lambdas =(a-0.5)/v(i);
lmat(ind)=(lambdas);
end
ind=ind+1;
end
for i =1:3
if(v(i)~=0)
lambdas=(((1-gb)/w)-0.5)/v(i);
lmat(ind)=(lambdas);
end
end
%lam=(max(lmat));
%added
lam=(min(lmat));
Is my matlab implementation correct?
Any help would be really appreciated.