MATLAB: Anyone tried function handle of blsprice

blspriceFinancial Toolboxfunction handleMATLAB

For those who are familiar with blsprice,please kindly ignore the next paragraph.
blsprice is in the financial toolbox to price Call/Put Options using Black-Scholes model. The syntax is: [Call, Put] = blsprice(Price, Strike, Rate, Time, Volatility, Yield) e.g.[Call, Put] = blsprice(100, 95, 0.1, 0.25, 0.5) returns call and put prices of $13.70 and $6.35, respectively.
I would like to create a function handle (like funh = @(x)blsprice(x,Strike, Rate, Time, Volatility, Yield) which enables me to control whether it is call or put, cos the result x would be depending on that. Does anyone knows how to do it? Thanks so much!

Best Answer

If you are trying to create a function handle that is able to select the second output of a function, then unfortunately there is no way to do that in MATLAB other than to use an auxiliary real function along the line of
function output = selectoutput(funct,x,number)
[t1,t2] = funct(x);
if number == 2
result = t2;
else
result = t1;
end
end