Error using fzero in a loop

4 ビュー (過去 30 日間)
Ajay Gupta
Ajay Gupta 2018 年 3 月 13 日
コメント済み: Ajay Gupta 2018 年 3 月 13 日
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!

採用された回答

Matt J
Matt J 2018 年 3 月 13 日
Your fun() does not return a scalar value (because v is not a scalar).
  1 件のコメント
Ajay Gupta
Ajay Gupta 2018 年 3 月 13 日
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDirect Search についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by