loop over all values in V

It says that my function in infinit but I don't know how to make it finit. Need to define a function that depends on a vector (V) and one variable (I2) to gives me a vector of I2 of each number in V
R_s = 0.005; % [Ω]
R_sh = 50; % [Ω]
n = 1; % ideality factor
f = @(I2,V) (I_p-I_o*(exp((V+R_s*I2)./V_t)-1)-V+R_s*I2/R_sh)/I2;
for k = 1:length(V);
I1(k) = fzero(@(I2) f(I2, V(k)),0);
end
figure (2)
plot(V, I1)
xlabel('Voltage [V]');
ylabel('Current [A]');
title('V-I characteristic');
P_max = max(V.*I1)

Answers (1)

DGM
DGM on 27 Nov 2021
If this is the expression you're using
% f is of the form A/I2
f = @(I2,V) (I_p - I_o*(exp((V+R_s*I2)./V_t)-1) - V + R_s*I2/R_sh)/I2;
% where I2 is zero
I1(k) = fzero(@(I2) f(I2, V(k)),0);
Then zero isn't a useful initial guess for the solver. You're trying to divide by zero. Pick a different initial guess. If you really want to stay close to zero, you can use eps instead of zero.

Categories

Find more on Programming in Help Center and File Exchange

Answered:

DGM
on 27 Nov 2021

Community Treasure Hunt

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

Start Hunting!