Approximate solutions for variables in matrix

3 visualizzazioni (ultimi 30 giorni)
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 Commento
Roger Stafford
Roger Stafford il 27 Apr 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?

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 27 Apr 2016
Your system might be linear, but it might depend on s and y in nonlinear ways. For example, a 4 x 4 rotation matrix is a linear system in itself, but it relies upon three angles in non-linear ways, and there is no way of uniquely recovering the angles from the final rotation matrix.
We therefore need to know more about the system to determine the difficulty of this.
  1 Commento
Amy Zou
Amy Zou il 27 Apr 2016
Oh yes, you are right. s and y are in some nonlinear functions. I was doing Johns matrix calculation for a SLM. s and y are the vertical retardation angle and rotation angle respectively. So there are sinusoidal function and exponential involved.

Accedi per commentare.

Più risposte (1)

John D'Errico
John D'Errico il 27 Apr 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.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by