Nernst Equation plotting in MATLAB
13 次查看(过去 30 天)
显示 更早的评论
I am unable to plot an Eout1 vs pH graph for changing quantities of Temperature and pH values.The code is:
%Constant Temperature and Changing pH
pH = 0:14;%pH Value
T = 300;% Temperature value in Kelvin
R = 8.3145;% Gas Constant
n = 1;% Number of moles
F = 96485;% Faradays Constant
E0 = 30e-3% Standard Cell Potential
Eout = -(E0 - (R*T/n*F)*pH)/1.0e+09 %Modified Nernst Equation
plot(pH,Eout)%plot firts graph
%Changing pH and Changing Temperature
T1 = 294:307;%Temperature Range
Eout1 = -(E0 - ((T1*R)/n*F)*pH)/1.0e+09
hold on
plot(pH,Eout1)
The first Eout vs pH graphplots fine. However, the Eout1 vs pH graph displays the error message:
Error using *
Inner matrix dimensions must agree.
I did try using "." operator in some combinations still no resolve.
Any ideas on solving this?
0 个评论
采纳的回答
Ameer Hamza
2020-5-28
Try this code, I changed the range of T1 and used element-wise operator in the equation for Eout1
%Constant Temperature and Changing pH
pH = 0:14;%pH Value
T = 300;% Temperature value in Kelvin
R = 8.3145;% Gas Constant
n = 1;% Number of moles
F = 96485;% Faradays Constant
E0 = 30e-3% Standard Cell Potential
Eout = -(E0 - (R*T/n*F)*pH)/1.0e+09 %Modified Nernst Equation
plot(pH,Eout)%plot firts graph
%Changing pH and Changing Temperature
T1 = 294:308;%Temperature Range % <===== changed range here
Eout1 = -(E0 - ((T1.*R)./n*F).*pH)/1.0e+09 % <===== used element wise operators.
hold on
plot(pH,Eout1)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!