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

3 次查看(过去 30 天)
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 个评论
Cesar García Echeverry
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?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Physics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by