Function as sum of functions in fsolve

3 次查看(过去 30 天)
I want to solve a set of nonlinear equations over two unknowns x(1) & x(2), e.g. in the form:
where factors a(i), b(i), k(j) and m(j) are known. I am not aware of how I can define the function: fun= @ (x) in a loop. Some help here would be really appreciated! Saeid

采纳的回答

Matt J
Matt J 2017-3-23
Just like you would without a loop. I assume you mean a loop over j...
asum=sum(a);
bsum=sum(b);
for j=1:length(k)
fun=@(x) myfun(x,asum,bsum,m(j),k(j));
xsol(j)=fsolve(fun,...)
end
function F=myfun(x, asum,bsum, mj,kj)
x1=x(1); x2=x(2);
F=[asum*x1^2+bsum*x1*x2^2 - kj ; you_fill_in_the_rest]
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by