loop over all values in V
조회 수: 1 (최근 30일)
이전 댓글 표시
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)
댓글 수: 0
답변 (1개)
DGM
2021년 11월 27일
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!