How to minimize the maximum error?
Ältere Kommentare anzeigen
Good day everyone,
I have this pack of data that are functions of three variables (say, x1, x2 and x3). How do I choose a linear approximating function that minimizes the maximum error between the linear function and the data? I'm getting some approximating functions with an other software that cannot provide this specific detail to choose between them, though, so I'm quite stuck.
On the other hand I've been suggested to use fminimax in MatLab, but it doesn't seem to be usable in this case (to me, and I'm not a "so experienced user" so I may be wrong).
Thank you so much in advance!
Stefano
Akzeptierte Antwort
Weitere Antworten (1)
Example:
rng('default')
n = 100;
x1 = rand(n,1);
x2 = rand(n,1);
x3 = rand(n,1);
y = rand(n,1);
f = [1; 0 ;0; 0; 0];
A = [-ones(n,1),ones(n,1),x1,x2,x3;-ones(n,1),-ones(n,1),-x1,-x2,-x3];
b = [y;-y];
[sol,fval] = linprog(f,A,b)
t = sol(1)
a = sol(2)
b = sol(3)
c = sol(4)
d = sol(5)
3 Kommentare
Stefano Gilardoni
am 8 Jun. 2023
Stefano Gilardoni
am 8 Jun. 2023
Torsten
am 8 Jun. 2023
Instead of
x1 = rand(n,1);
x2 = rand(n,1);
x3 = rand(n,1);
y = rand(n,1);
you just have to supply your data as column vectors.
Kategorien
Mehr zu Solver Outputs and Iterative Display finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!