Nernst Equation plotting in MATLAB
13 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Ameer Hamza
on 28 May 2020
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)
2 Comments
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!