How can I plot one array and an array of roots?
3 views (last 30 days)
Show older comments
I wanted to plot T array vs. the array that is made of the roots of E. I used vpasolve to find the roots and called it X. But I couldn't construct the array of the roots. Since for every T value there is a E value I thought that T vs X can be plotted. How can I fix this?
clc;
clear all;
syms E
R=0.008314; %kj/mol.K
dH=-92.2; %kj
dS=-0.1987; %kj/mol.K
P=5; %bar
T=298:400; %Kelvin
n=length(T);
X=zeros(1,n);
for k=1:n
dG(k)=dH-T(k).*dS;
%K=exp(-dG/(R.*T));
y_NH3= (E/(2-E));
y_N2= ((1-E)/(4-2*E));
y_H2= ((3-3*E)/(4-2*E));
K=(((E/(2-E))^2)/(((1-E)/(4-2*E))*(((3-3*E)/(4-2*E))^3)*(P^2)))==exp(-dG(k)/(R.*T(k))); %equilibrium constant
X(k)= vpasolve(K,E,[0,1])
end
plot(T,X)
2 Comments
Answers (0)
See Also
Categories
Find more on Line 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!