# loop over all values in V

2 views (last 30 days)
Gisela Subirats Gonzalez on 27 Nov 2021
Answered: DGM on 27 Nov 2021
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)

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.