Nernst Equation plotting in MATLAB

13 visualizaciones (últimos 30 días)
Shay
Shay el 28 de Mayo de 2020
Comentada: Ameer Hamza el 28 de Mayo de 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?

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by