Hi , I'm new to matlab with fsolve and I get not enough input arguments everytime. Can someone please as what am I missing. Many Thanks
Show older comments
function AAHydro
p = parameter;
Delta_T_adiabat = p.dTad
Zulaufkonzentration = p.c_AA_0
x0 = [-5;-5];
options= optimoptions('fsolve','Display','iter'); % Option to display output
[x,fval] = fsolve(@myfun, x0, options); % Call solver
end
function dx = myfun(x)
% x(1) = Concnetration in the reactor
% x(2) = Temperature of reactor
p= parameter;
dx(1) = (p.c_AA_0-x(1))/p.tau + p.kinf*exp(-p.EA*1000/(p.R*x(2)))*(x(1))^p.n;
dx(2) = (p.Tin - x(2))/p.tau + p.dTad*p.kinf*exp(-p.EA*1000/(p.R*x(2)))*x(1))^p.n;
dx = dx';
end
function p = parameter()
p.R = 8.3145; % [J/molK]
p.Tin = 30 + 273.15; % [K]
p.n = 0.94;
p.rho = 1000; % [kg/m^3]
p.cp = 4.186; % [kJ/kgK]
p.vol = 0.56; % [l]
p.dHr = -55.5; % [kJ/mol]
p.MAA = 102.09; % [g/mol]
p.rho_AA = 1.08; % [g/cm^3]
% p.Vdot_AA = 1.114 ; % [l/h]
p.Vdot_AA = 0.3 ; % [l/h]
p.Vdot_W = 3.6; % [l/h]
p.Vdot_total = p.Vdot_AA + p.Vdot_W; % [l/h]
p.tau = p.vol/p.Vdot_total*60*60; % [s]
p.c_AA_0 = ((p.Vdot_AA*p.rho_AA*1000)/p.MAA)/p.Vdot_total; % [mol/l]
p.dTad = -p.dHr*p.c_AA_0/(1e-03*p.rho*p.cp); % [K]
p.kinf = 139390; % [1/s]
p.EA = 44.35; % [kJ/mol]
end
Accepted Answer
More Answers (1)
raviteja peri
on 25 Nov 2015
Edited: Walter Roberson
on 25 Nov 2015
4 Comments
Stephen23
on 25 Nov 2015
@ raviteja peri: is this an answer to your own question? The Answer fields are only supposed to be for actually answering a question.
Do you have a question?
raviteja peri
on 25 Nov 2015
Sure, but this is an Answer. We can see that it is an answer because the text-field title was "Answer this question", where you posted the code. It helps us when you stick to using the comments for commenting and adding more information on your original question. The comment links are titled "Comment on this Answer" or "Comment on this Question".
You still have not asked a question, so it is not clear why you have shown us this code. IS the code doing something that you do not expect? How can we help you with it? It would be nice to get an explanation from you, as our mindreading abilities are not very well developed.
Walter Roberson
on 25 Nov 2015
The user posted the code in a new question which has received an answer.
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!