Filter löschen
Filter löschen

Nernst Equation plotting in MATLAB

13 Ansichten (letzte 30 Tage)
Shay
Shay am 28 Mai 2020
Kommentiert: Ameer Hamza am 28 Mai 2020
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?

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 28 Mai 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 Kommentare
Shay
Shay am 28 Mai 2020
Thank you for the solution.
Ameer Hamza
Ameer Hamza am 28 Mai 2020
I am glad to be of help!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by