Conversion to double from function_handle is not possible.
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 part of the code is where the error occurs. The error is: Conversion to double from function_handle is not possible, and occurs in the line y(1,i) =@(T) x(1,i).*(10.^(logP(T)./P_total)); .
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
T = sym('T', [1 n]);
ytotal = zeros(1, n);
for i = 1:n
logP = @(T) a(i) - (b(i)./(T+c(i)));
y(1,i) =@(T) x(1,i).*(10.^(logP(T)./P_total));
ytotal = ytotal + y(i);
y(i) = y(i+1);
end
Accepted Answer
More Answers (0)
Categories
Find more on Assumptions 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!