Function used in fsolve with array coefficients
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Saeid
am 21 Okt. 2018
Kommentiert: Walter Roberson
am 22 Okt. 2018
Using fsolve I want to solve an equation for x which has the follwing form:
a1*f1(x)+a2*f2(x)+...+ai*fi(x)=0
where ai are known coefficients (typically read from an inout excel file), i is the index going from 1 to n and fi are some nonlinear functions of x. So the routine to solve for x should look something like this
ai=xlsread('MyFile.xls',1) Xi=fsolve(@MyFun,X0) function MyFun=MyFun(x) MyFun=... end
How can I define MyFun knowing that everytime I read a new excel file the number of ai will change?
4 Kommentare
Walter Roberson
am 22 Okt. 2018
You said that the fi are functions. You are reading the ai values in, but not the functions. You have one for each ai value, and you have an indefinite number of ai values. So you must either have a maximum number of ai values and a list of corresponding functions (of which you use the first so-many) or else you must have a way of computing the functions given the index to the function.
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!