fsolve with structure of functions in a cell
Show older comments
Hi,
I'm trying to solve a structure of 10 equations using fsolve, but so far, Matlab refuses to use my cell as input:
eq =
Columns 1 through 5
[function_handle] [function_handle] [function_handle] [function_handle] [function_handle]
Columns 6 through 10
[function_handle] [function_handle] [function_handle] [function_handle] [function_handle]
Error using lsqfcnchk (line 114)
FUN must be a function handle.
Error in fsolve (line 198)
funfcn = lsqfcnchk(FUN,'fsolve',length(varargin),funValCheck,gradflag);
Error in NRTL (line 36)
fsolve({eq{1}; eq{2}; eq{3}; eq{4}; eq{5}; eq{6}; eq{7}; eq{8}; eq{9}; eq{10}},[0,0 0,0 0,0 0,0 0,0 0,0 0,0
0,0 0,0],options)
Matlab code (simplified):
modelRaf(i) = (((T(1,i).*G(1,i).*x_raf(1,j)) + (T(2,i).*G(2,i).*x_raf(2,j)) ... % a very long model
for i=1:2
eq{i} = str2func(['@(T) exp(',char(modelRaf(i)),') .* ',num2str(x_raf(2,i))]
end
options = optimoptions('fsolve','Display','none','PlotFcn',@optimplotfirstorderopt);
fsolve(eq,[0,0 0,0],options)
The model works (used it many times). Any sugestions?
1 Comment
Peter
on 27 May 2016
Accepted Answer
More Answers (1)
Peter
on 23 Apr 2018
0 votes
1 Comment
Walter Roberson
on 23 Apr 2018
We leave solved problems available so that other people can learn from them.
Categories
Find more on Solver Outputs and Iterative Display 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!