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?

采纳的回答

Ameer Hamza
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 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by