How can I plot one array and an array of roots?

3 views (last 30 days)
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
KSSV
KSSV on 16 Jun 2021
I am getting the plot of T Vs X....you getting any error?
Ecem Ünal
Ecem Ünal on 16 Jun 2021
oh it is fixed by itself. I literally spend hours to fix this, every time it showed an empty plot. thank you by the way!

Sign in to comment.

Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!