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

curve fittinglsqlinMATLABmultiple data setsOptimization Toolboxsimultaneous equation solving

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.

Best Answer

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.