Error using fzero in a loop

6 views (last 30 days)
Ajay Gupta
Ajay Gupta on 13 Mar 2018
Commented: Ajay Gupta on 13 Mar 2018
I'm trying to solve a transcendental equation for "i", for all values in my "v" array. I'm getting an error when using fzero in a loop:
Operands to the || and && operators must be convertible to logical scalar values.
Error in fzero (line 327)
elseif ~isfinite(fx) || ~isreal(fx)
Error in RealisticDiodeModel (line 15)
i_arr(index) = fzero(fun, v(index));
Here's my code
for index = 1:n
disp(index);
fun = @(i)IO.*(exp((v + i.*Rser)./(kToq.*eta)) - 1) + (v./Rsh) + i.*(1 + (Rser./Rsh)) - IL;
i_arr(index) = fzero(fun, v(index));
end
Where "n" is the size of my "v" array, and "Rser", "kToq", "eta", "Rsh", "IO", and "IL" are predefined constants. Thanks in advance!

Accepted Answer

Matt J
Matt J on 13 Mar 2018
Your fun() does not return a scalar value (because v is not a scalar).

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!