Error using fzero in a loop

6 vues (au cours des 30 derniers jours)
Ajay Gupta
Ajay Gupta le 13 Mar 2018
Commenté : Ajay Gupta le 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!

Réponse acceptée

Matt J
Matt J le 13 Mar 2018
Your fun() does not return a scalar value (because v is not a scalar).
  1 commentaire
Ajay Gupta
Ajay Gupta le 13 Mar 2018
Thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by