How to plot different lengths of vectors?
Show older comments
Hello, I have this code
I want to plot (T vs yCO) but for some reason I have 250 values from "eqn" but 125 temperature values. So, naturally I am getting the error of different lengths. Can anyone help me?
T = 298:1:422; %Temperature Values
K1 = exp((-deltaHrxn1*1000 + T.*deltaSrxn1.*1000)./(R.*T)); %equilibrium constant for reaction 1
K2 = exp((-deltaHrxn2*1000 + T.*deltaSrxn2.*1000)./(R.*T)); %equilibrium constant for reaction 2
syms ksi1 ksi2
eqn = [(((ksi1)./(1-ksi1-ksi2))./((2-2*ksi1-ksi2)/(4-2*ksi1))^2)==K1, (((1+ksi2).*(2-2*ksi1-ksi2))./((-ksi2).*(1+ksi2)))==K2];
S = arrayfun(@(X)vpasolve(X), eqn, 'uniform', 0);
S = [S{:}];
S.ksi2; %ksi2 = 0 for all values
S.ksi1;
ksi2 = 0;
ksi1 = [S.ksi1];
yCO = ((1 - ksi1)./(4 - 2*ksi1))
1 Comment
vimal kumar chawda
on 11 Jun 2021
There might be few conditions are as
1- Temp will be same although yCO still getting value and last it will be equal number.
2- you have to take equal number , which you can delete or not considering yco values.
3- Increase the interval of the temperature so that both index will be equal.
Please put the whole code it will never going to be answer in the short time like half code ?
Accepted Answer
More Answers (1)
Sulaymon Eshkabilov
on 12 Jun 2021
Check your constants, R, deltaHrxn1, deltaHrxn2,...
Note that the solutions might have two components, real and imaginary parts
deltaHrxn1 = 3;
deltaSrxn1 = 3.5;
deltaSrxn2 = 2*pi;
deltaHrxn2 = pi/2;
R = 5;
T = 298:422; %Temperature Values
...
plot(T, real(yCO),'b', T, imag(yCO), 'r'), legend('Real','Imag') %% Works ok
Categories
Find more on Programming 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!