How to minimize the maximum error?
이전 댓글 표시
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
채택된 답변
추가 답변 (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
Stefano Gilardoni
2023년 6월 8일
Stefano Gilardoni
2023년 6월 8일
Torsten
2023년 6월 8일
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.
카테고리
도움말 센터 및 File Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!