
merging two graphs for two chemical reactions
3 views (last 30 days)
Show older comments
i am a bigenner and i needed to caluculate the concentration of two reactions, ((2 N2O5 ⟶4 NO+ O2 ))and ((2 NO2 ⟶2 N2+O2 ), ( the concentration of N2O5 is 1.4 M) .
so here is the code:
k1 = 5.2*10^-3;
a0 = 1.4 ;
k2 = 3.4*10^-5;
%reaction 1
for t = 1:1:10000
A(t) = exp(-k1*t*2 + log(a0));
end
for t = 1:1:10000
B(t) = exp(+k1*t*4 );
end
for t = 1:1:10000
C(t) = exp(+k1*t);
end
%A B C - concentration of H2O5 NO O2
%reaction 2
for t = 1:1:10000
D(t) = -exp(-k2*t*2 +log(2.154)) + exp( k1*t*4);
end
for t = 1:1:10000
E(t) = exp(k2*t);
end
for t = 1:1:10000
G(t) = + exp( k2*t + log(3.8)) + exp(+k1*t);
end
% D E G - oncentration of NO N2 O2
t = [1:10000];
plot (t,A,':',t,D,'r',t,G,'g',t,E,'b')
title('reaction 1');
xlabel('t[sec]');
ylabel('concentration[M]')
legend('N2O5',' NO ', 'O2 ', 'N2')
so the problem is that i want to have the first reaction at the bigenning , so the concentration of NO and O2 starts at 0 then get bigger while N2 stays 0 ,
and when the 2nd reaction starts , N2O5 is at 0 , while NO and O2 will decrase. here i get just the concentrations of the secound reaction, how can I solve this thing ?
1 Comment
darova
on 14 May 2019
It's your plot (t = 0..50). Can you please explain on image (draw in paint or something)?

Also, you don't have to loop every time you want calculate something. Why do you name your variables as A,B,C if you already have short and clear NO, N2?
t = linspace(0,50,100); % time 0 .. 50 (100 points)
H2O5 = exp(-k1*t*2 + log(a0));
NO = exp(k1*t*4);
O2 = exp(k1*t);
% you can plot every equation separately
plot(t,H2O5,':')
hold on
plot(t,NO,'r')
plot(t,O2,'g')
plot(t,N2,'b')
hold off
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!