Linear fitting with 2 variables
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi everybody,
I'm trying to solve a linear fitting using Matlab. In particular my function is: y=a*x+ b+ c*f, where I have y that it is a matrix 3x15, x is a vector 1x15 and f is a vector 1x3001.
Is there any particular function that is able to fit the coefficients a,b,c directly? Also taking into account that the vectors are not all of the same lenght.
Thank you so much.
PS. I do not have the GADS_Toolbox (for the function createOptimProblem).
댓글 수: 2
채택된 답변
추가 답변 (1개)
Alan Weiss
2021년 10월 14일
I think that the Problem-Based Optimization Workflow would help. Write your optimization variables a, b, and c as you have done, then set the objective as the minimization of the sum of squares of differences between your data and your result using the optimization variables (I cannot be more specific here because I do not understand what you are etrying to minimize).
Alan Weiss
MATLAB mathematical toolbox documentation
댓글 수: 9
Alan Weiss
2021년 10월 14일
The objective I wrote is a scalar optimization expression. What did you write?
You could also try this expression:
objective = sum(sum((y - ex1 - ex2 - ex3).^2));
Alan Weiss
MATLAB mathematical toolbox documentation
참고 항목
카테고리
Help Center 및 File Exchange에서 Least Squares에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!