Does lsqlin give different solution if the rows of C matrix and d matrix are changed accordingly?

1 visualizzazione (ultimi 30 giorni)
I have two curves(or datasets) which are to be fitted of the form, C1.x=d1 and C2.x=d2, where x is the solution which should satisfy both equations. Here C1 has several subsets of data, for example C1=[c11; c12; c13...] with an associated fit data d1=[d11; d12; d13;..]. Similarly C2 has several subsets of data, for example C2=[c21; c22; c23...] with an associated fit data d2=[d21; d22; d23;..]. So I had clubbed both C1 and C2 into a single matrix and d1 and d2 into single matrix, so that I have the form C=[C1;C2] =[c11;c12;c13;c21;c22;c23] and d=[d1;d2]=[d11;d12;d13;d21;d22;d23]. Then upon solving using lsqlin, I get a solution 'x'.
Alternatively, upon merging the C1 and C2 in different manner, say C=[c11;c21;c12;c22;c13;c23] and correspondingly reordering d as d=[d11;d21;d12;d22;d13;d23] and then solving using lsqlin, I get a solution 'x'.
The solution 'x' for both the cases seemed to be different for my problem in hand. So I tried it with a small random dataset, but here the solution 'x' was same in both cases.
Now I in confusion, if changing the rows of the C matrix and correspondingly changing the d matrix, yield the same solution or not?
Or, can't lsqlin be used for curve fitting multiple independent datasets?
Thanks in advance.

Risposta accettata

Torsten
Torsten il 22 Ago 2016
Modificato: Torsten il 22 Ago 2016
I don't understand your notation, but here is an example:
If
C1=[1 6
4 8];
d1=[4
7];
C2=[9 2
3 6
8 1]
d2=[1
0
6]
you have to define C and d as
C=[1 6
4 8
9 2
3 6
8 1]
d=[4
7
1
0
6]
Best wishes
Torsten.
  3 Commenti
Torsten
Torsten il 22 Ago 2016
Modificato: Torsten il 22 Ago 2016
It is possible, but unlikely that you get different solutions.
You should check whether norm(C*x-d) changes. If not, everything is fine. If it changes, you've made a mistake in the setup.
Best wishes
Torsten.
Thanigaivel Raja T
Thanigaivel Raja T il 22 Ago 2016
yup...upon changing rows in C and correspondingly in d, the solution x is the same(whatsoever).. I had made mistake in concatenation of matrices forming 'd', so got messed up.
Thanks for your answer, I needed an assertion from someone before I could over check my tedious code for any errors!

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by