Approximate solutions for variables in matrix
Afficher commentaires plus anciens
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 commentaire
Roger Stafford
le 27 Avr 2016
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?
Réponse acceptée
Plus de réponses (1)
John D'Errico
le 27 Avr 2016
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.
Catégories
En savoir plus sur Calculus dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!