Error converting from sym to double: Unable to convert expression into double array
Show older comments
Hi,
I am having a problem with the syms function in matlab and I was wondering if anyone could help. The help would be greatly appreciated.
The code is to caclulate the bubblepoint of a mixture which contains n components.
The beginning of the code can be seen below. The last line is where the error :Error converting from sym to double: Unable to convert expression into double array
occurs.
CODE:
P_total = input('Please enter the total pressure in mm Hg: \n');
n = input('Please enter the number of components:\n');
x = zeros(1, n); % Liquid phase mole fractions
y = zeros(1, n); % Vapour phase mole fractions
load Antoine_coefficients.txt % reading in the file which contains the Antoine Coefficients of the components
fprintf(' 1 = Acetaldehyde\n 2 = Acetic Acid \n 3 = Acetone \n 4 = Acetylene \n 5 = Ammonia\n 6 = Argon\n 7 = Benzene \n')
for ite = 1: n
fprintf('Please enter the corresponding number for the component %i in the feed stream: \n', i);
comp(i) = input(' ');
data1 = Antoine_coefficients(comp(i),:);
a(i) = data1(1);
b(i) = data1(2);
c(i) = data1(3);
end
for i = 1:1:n
fprintf('Please input the liquid phase mole fraction of component %i: \n', i);
x(1, i) = input(' ');
end
% bubble point temp. calc
syms T [1:n]
for i = 1:1:n
% y1 = x1 * Psat/Ptotal
y(i) = x(i).*(10.^Antoine(a(i), b(i), c(i), T)./P_total); % Antoine is the user defined function which calculates Psat
end
I would really appreciate any help.
Thank in advance!
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!