How to define a vector of many (a lot of) equation ?

5 views (last 30 days)
Hello community. I hope you are doing well despite the curent circomstances (COVID-19, lockdown, etc.).
How can I define a vector of many (a lot of) equations (or functions) ? What I want should be like [f(a1,x)==0,f(a2,x)==0,f(a3,x)==0,...,f(an,x)==0] where f is a nonlinear function and a=(a1,a2,...,an) is a vector of exogenously provided parameters, and x a real unknown. The problem is that the number of equations (functions) n is very large (and even dynamic), and I cannot consider writing this vector in full extension. Is there any way fast and elegant ?
Actually, what I need is to solve the nonlinear equation f(a,x) == 0 for many different values of a, and so independently. One way is to just put a loop around and use the fzero routine, which I did. It works, but its execution time is long. I would like if there is a more efficient way to do this. My intention is that if I can define the vector above I would use vpasolve to do that. Any (other) suggestion ?
Thank you.
  1 Comment
Cesar García Echeverry
Cesar García Echeverry on 28 Apr 2020
How many set of non-linear equation do you have?
function f=system(x)
f=[x(1)^2-2*x(2);
3*x(1)^2+5*x(2)]; %and so on.
% or
% f(1)=x(1)^2-2*x(2);
% f(2)=3*x(1)^2+5*x(2);
end
you can define @ funtion defining variables (x,y etc) and later call de equations.
f=@(x) [x(1)^2-2*x(2);3*x(1)^2+5*x(2)];
or
f=@(x) system (x);
You can define your problem?

Sign in to comment.

Answers (0)

Categories

Find more on Problem-Based Optimization Setup 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!