how to sum elements

3 ビュー (過去 30 日間)
Egor Popov
Egor Popov 2022 年 5 月 20 日
編集済み: Egor Popov 2022 年 5 月 21 日
I have a code in which, in addition to displaying graphs, you need to get the sum of the elements and display them on a common graph. How can I correctly sum of loop elements (GA, GH, GUV, GGAS, GGRAINS)? ty
clear all
n=1;
z=1;
G=1.4;
Tgr = 15;
N_t = 100000;
T_ini = 10;
T_fin = 1e4;
dT=(1e4-1e1)/N_t;
ne=1e-4;
Rdiss = 5.6e-11;
nh2 = 2.6e-9;
k4 = 6.4e-10;
for k=1:N_t
T(k) = T_ini + dT*(k-1);
k60 = 3.0d-18*T(k)^0.5/(1+4.0d-2*(T(k)+Tgr)^0.5+2d-3*T(k)+8d-6*T(k)^2)/(1+1.0d4*exp(-600/Tgr));
ncrh = 10.^(3-0.416*log10(T(k)/10000)-0.327*(log10(T(k)/10000)^2));
ncrh2 = 10.^(4.845 - 1.3*log10(T(k)/10000)+1.62*(log10(T(k)/10000))^2);
nharmonic = 1.0/(10.0/ncrh + 1/ncrh2);
k2 = 4d-9/T(k)^0.17;
GGAS(k)= (2.93e-12*k2*nh2 + 5.65e-12*k4*nh2)*nh2*nharmonic;
GGRAINS(k) = 7.16d-12*k60*nh2*nharmonic;
fi=G*T(k)^0.5/(0.5*ne);
e=(4.9e-2*(1+4e-3*fi)^-1)+(3.7e-2*((T(k)/10000)^0.7)*(1+2e-4*fi)^-1);
GA(k)=1.3e-24*e*1.4*1*1;
GH(k) = 6.4e-13*Rdiss*nh2;
GUV(k) = 2.7e-11*Rdiss*nh2;
end
hold on
%figure(1001)
loglog (T,GA)
loglog (T,GH, '-.')
loglog (T,GUV, '--')
loglog (T,GGAS, ':.')
loglog(T,GGRAINS)
set(gca,'yscale','log')
set(gca,'xscale','log')
legend ('GA','GH','GUV','GGAS','GGRAINS')

回答 (1 件)

Voss
Voss 2022 年 5 月 20 日
GA_sum = sum(GA);
GH_sum = sum(GH);
% etc.

カテゴリ

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

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by