clc; clear all; %%%%% Input Variables %%%%% k = 1.380648e-23 T = 300 q = 1.60217646e-19 R = 1 I = 0; Ith = 5e-9; %%%%% Input Variables %%%%% j = 1; %%%%% Iterate over the PV equation %%%%% for Iseed=1:0.001:1.2 I(j)=(Iseed-1); V(j) = ((k*T)/q)*log((I(j)/Ith)+1); j=j+1; end I = fliplr(I); % Flip axes from fourth to first quadrant % Plotting %figure(1); plot(V,I,'r'); axis([0 0.6 0 0.25]); grid on; hold on; %%%%% New computation taking Rser %%%%% clc; clear V; clear j; %%%%% Clear and set vars (not really necessary for all vars) k = 1.380648e-23 T = 300 q = 1.60217646e-19 R = 1 Ith = 5e-9; j = 1; %%%%% Iterate over the PV equation, taking account on Rser %%%%% for Iseed=1:0.001:1.2 I(j)=(Iseed-1); V(j) = ((k*T)/q)*log((I(j)/Ith)+1); I(j) = Ith*(exp((V(j)+(I(j)*R))/0.0259)-1); I(j) = I(j)*0.0004577; % Some scaling due to weird computation results %V(j) = V(j) - I(j)*R; % Uncomment and comment above to see the effects of % taking the PV as a black box j=j+1; end I = fliplr(I); % Flip axes %Plotting %figure(2); plot(V,I,'b'); legend('Ideal IV curve', '1 Ohm ESR') axis([0 0.6 0 0.25]); grid on; hold on;