Approximate solutions for variables in matrix
이전 댓글 표시
I'm trying to solve two variables in a linear system to match experiment data. I have a theoretically calculated 4x4 matrix X, which contains two unknown variables s and y. Another 4x4 matrix Data has numbers measured from experiment. Now I need to find the value of s and y that work best for matrix X and Data to be the same. How can i do that?
Also, should I define s and y as symbolic variables in matrix calculation?
Thanks!
댓글 수: 1
Roger Stafford
2016년 4월 27일
Your description would indicate that you have four equalities to satisfy, (at least approximately.) Since four equations is more than two unknowns, you will in general be unable to find an exact solution. What are you looking for as a measure of the quality of an approximation - the least mean square among the four differences, for example?
채택된 답변
추가 답변 (1개)
John D'Errico
2016년 4월 27일
If I read you properly, you are trying to solve the problem
X(s,y) = data
where data is a 4x4 matrix, and X is also a 4x4 matrix, effectively a function of s and y, so each element X(i,j) is a nonlinear function of the parameters s and y.
Just solve this as a nonlinear least squares problem. Use lsqnonlin, or lsqcurvefit, from the optimization toolbox. Do NOT make the parameters symbolic. Just set up a function handle for X(s,y), that can generate the matrix X for any give pair of parameters s and y.
If X is a function of two arguments s and y, then convert it to a function of a vector of length 2, as below:
Xfun = @(sy) X(sy(1),sy(2));
Then call lsqcurvefit.
카테고리
도움말 센터 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!