Check if function handle is nonlinear with Matlab
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Daniela Würmseer
am 2 Apr. 2022
Kommentiert: Torsten
am 3 Apr. 2022
Hello,
is it possible to check with matlab if a Function Handle is nonlinear?
For example:
f1=@(x) x(1)+x(2)-5;
f2=@(x)10*x(1)-x(1)^2+4*x(2)-x(2)^2;
So here i would need something which tells me that f1 is linear and f2 is nonlinear. Thanks
1 Kommentar
Paul
am 2 Apr. 2022
The first function is linear in x, I suppose, but is not linear from a system theoretric perspective, as it doesn't satisfy superposition or scaling. Just want to make sure we're clear on the definition of linear in the question.
Akzeptierte Antwort
Torsten
am 2 Apr. 2022
Bearbeitet: Torsten
am 2 Apr. 2022
Call your function handle f with symbolic vectors x and y and a symbolic scalar a and check whether
f(x+y) - (f(x) + f(y)) - f(0) == 0
f(a*x) - a*f(x) == 0
4 Kommentare
Torsten
am 3 Apr. 2022
I could just define those functions in nonlincon of fmincon but nonlincon is normally for nonlinear functions. Would it be a problem to use nonlincon with linear functions (normally not or)?
No problem. Implementing linear constraints either in lb,ub or A, Aeq, b, beq should only make the code run faster.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!