필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
Idossou Marius Adom
Idossou Marius Adom 2020년 4월 28일
댓글: Cesar García Echeverry 2020년 4월 28일
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
Cesar García Echeverry 2020년 4월 28일
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에서 Problem-Based Optimization Setup에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by