I_sc value is an object of the sfit. The solve function requires a polynomial expression. Using the attributes(coeffvalues,coeffnames) of sfit object the function handle for the polynomial can be obtained.
% Extract coefficient names
names = coeffnames(I_sc);
I_sc_expression = 0;
% Looping to construct the polynomial expression.
for i = 1:numel(names)
name = names{i};
I_sc_expression = I_sc_expression + I_sc.(name)* (x^str2double(name(2)) * y^str2double(name(3)));
end
eqn = I_sc_expression == I_sc_max;
S = solve( eqn, x ); % Gives two solutions
S1= S(1); % Extracting one solution
func =@(y)subs(S1,y);
