The if loop is continuing even after the condition is false.
Afficher commentaires plus anciens
I have to find the max value of R in specified range of the SOC values and the answer should be 0.2554 but the if loop is giving answer as 0.2552. The loop is iterating for the values of 'j' even after the condition is false. I have attached the matlab code and the data file.
clear all
clc
load data
Ezero=(0.0026.*temp)+(7.9387*10^(-4).*temp.*SOC)+(0.0016.*temp.*(SOC).^2)+2.5625; %Open circuit voltage
R=V-Ezero; %Battery internal resistance
figure (1)
plot(SOC,V,'-r','LineWidth',1); %Plot of voltage vs SOC
xlabel('SOC(%)');
ylabel('Voltage(Volts)');
title('Voltage vs SOC plot');
grid on
figure (2)
plot(SOC,Ezero,'-k','LineWidth',1)
xlabel('SOC(%)');
ylabel('Open circuit voltage(Volts)');
title('Open circuit voltage vs SOC plot'); %Plot of Open circuit voltage vs SOC
grid on
figure(3)
plot(SOC,R,'-b','LineWidth',1)
xlabel('SOC(%)');
ylabel('Internal Resistance(Ohm)');
title('Internal Resistance vs SOC plot'); %Plot of Resistance vs SOC
grid on
%% RUn
socl= find(SOC>=0.6 & SOC<=0.8);
RS=R(socl);
for j=2:length(RS)
if(RS(j)>RS(j-1)) %this loop here is giving wrong value
Rmax=RS(j);
end
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
