Intersection of two curves in matlab

3 ビュー (過去 30 日間)
Rajat Powade
Rajat Powade 2022 年 6 月 15 日
回答済み: Star Strider 2022 年 6 月 15 日
Hi there i need to calculate intersection point of two curves. Please help i am attaching my code
clc
%crate=0:1:10;
G=-I_BT;
h=4000;%no. of cycles
T=30+273;%temp in kelvin
R=8.314;%universal gas const
capa=200;%battery capacity
%batt_curr batt_HESS=[1,2,3,4]
A=[G];
[n, xout] = hist(A,60);
c_rate=abs((xout.*(n>0))/capa);
B = exp(1.226*exp(-0.2797*c_rate)+9.263);
A_h=abs(xout.*(n>0)).*(n/3600);
Dk=zeros(h,2);
for i=1:h
q_k=B.*exp((-31700+370.3.*c_rate)/(R.*T)).*((i.*A_h).^0.55);
Qk=100-sum(q_k);
Dk(i,:)=Qk;
end
figure(3)
plot(Dk,'LineWidth', 4)
set(gca,'fontsize', 18);
%set(gca,'LineWidth', 4);
ylim([0,100]);
yline(80)
xlabel('No. of Cycles');
ylabel('Capacity Retention %');
%legend('Battery Capacity Retention');

回答 (2 件)

Torsten
Torsten 2022 年 6 月 15 日
編集済み: Torsten 2022 年 6 月 15 日
clc
%crate=0:1:10;
G=-I_BT;
h=4000;%no. of cycles
T=30+273;%temp in kelvin
R=8.314;%universal gas const
capa=200;%battery capacity
%batt_curr batt_HESS=[1,2,3,4]
A=[G];
[n, xout] = hist(A,60);
c_rate=abs((xout.*(n>0))/capa);
B = exp(1.226*exp(-0.2797*c_rate)+9.263);
A_h=abs(xout.*(n>0)).*(n/3600);
fun = @(x) (100 - integral(@(t)B.*exp((-31700+370.3.*c_rate)/(R.*T)).*((t.*A_h).^0.55),0,x)) - 80;
intersection = fzero(fun,3500)

Star Strider
Star Strider 2022 年 6 月 15 日
The ‘I_BT’ variable is missing, so I cannot run the code. However getting the intersection of the exponential and the line is straightforward —
x = 0:4000;
Dk = 100*exp(-6.5E-5*x);
Cv = 80;
xv = interp1(Dk,x,Cv)
xv = 3.4330e+03
figure
plot(Dk, 'LineWidth',2)
hold on
plot(xv, Cv, 'sr', 'MarkerSize',15, 'LineWidth',2.5)
hold off
xlim([min(x) max(x)])
ylim([0 100])
yline(Cv)
.

カテゴリ

Help Center および File ExchangeSimulink についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by