I need to apply constrain using least square non negative function in Matlab

Hi , I am working on Tikhonov Regularization and trying to reconstruct the absorption densities of experimental data using least square non negative function in matlab which takes my sensitivity matrix and measured data and solves for X unkonwn values, Now i want to apply constrain that during fitting it check whether my reconstruction is greater than or equal minimum values i assign manually and less than equal to maximum value is assign manually, the problem is lsqnoeng does not support upper bound and lower bound , can some one give me an idea how cani apply my constrain using lsnoneg

Risposte (1)

Use lsqlin instead.

12 Commenti

but it is not giving me the results like lsqnoneg
If you set the lower bounds to 0 in lsqlin, lsqnonneg and lsqlin should give the same results (at least if your matrix C has full rank). But you wrote you wanted to set different bounds - so use "lsqlin" for this.
Actually i am working on ill posed problem so the sensitvity is not full rank , the upper and lower bounds are positive, i want in every iteration lsqnoneg to check whetehr the the value is greater than ot equal to specific value and less than or equal to specific value , so it is hard to put this in lsqnineg , lsqlin i tried but it converge so fast that it takes few seconds unlike lsqnoneg which takes time to converge ,
lsqlin i tried but it converge so fast that it takes few seconds unlike lsqnoneg which takes time to converge ,
And what's the problem if a solver only takes a few second to converge ? You are not satisfied with the result ?
Actually i am working on ill posed problem so the sensitvity is not full rank
But you said you are using Tikhonov regularization. So, it shouldn't be ill-posed anymore.
If you are getting a radically different solution with lsqlin from what you expect, I imagine it is because the bounds drastically alter the solution, so perhaps you made the bounds excessively tight. I would point out, though, that you haven't shown us any code so far in the conversation. This limits our ability to visualize what you are doing, and to theorize about problems.
Actually , i tried to change limits and put lower bound as zero and upper bound, but still the results are not same , the reconstruction is very bad
There's nothing we can say. You still haven't provided code for us to run.
its a big code shoud i give the whole code with experimental data or the portion of reconstruction i am doing?
You should attach a .mat file with the inputs you are giving both to lsqnonneg and lsqlin.
smoothening = Smoothening_roi(number_of_pixels);
max_L = max(abs(smoothening(:)));
smoothening = smoothening/max_L;
Null_matrix=zeros(number_of_pixels,1);
Tikh_Input.Integrated_Absorption_Line_1=IA.Integrated_Absorbance_per_pixel_line_1;
Tikh_Input.Integrated_Absorption_Line_2=IA.Integrated_Absorbance_per_pixel_line_2;
lambda_Tikh =1;
lambda_Tikh_2 =1;
Combined_Coeff_Matrix=[Coeff_Matrix_sparse ; lambda_Tikh.*smoothening];
Combined_Coeff_Matrix_2=[Coeff_Matrix_sparse ; lambda_Tikh_2.*smoothening];
Tikh_Input.Integrated_Absorption_Line_1 = IA.Integrated_Absorbance_per_pixel_line_1; % Line 1
Tikh_Input.Integrated_Absorption_Line_2 =IA.Integrated_Absorbance_per_pixel_line_2; % Line 2
Combined_projection_line_1=[Tikh_Input.Integrated_Absorption_Line_1;Null_matrix];
Combined_projection_line_2=[Tikh_Input.Integrated_Absorption_Line_2;Null_matrix];
lb1 = zeros(1601,1);
ub1=[];
lb2 =zeros(1601,1);
ub2=[];
z =lsqlin(Combined_Coeff_Matrix, Combined_projection_line_1, [], [], [], [], lb2, ub2);
y= lsqlin(Combined_Coeff_Matrix, Combined_projection_line_2, [], [], [], [], lb1, ub1);
We are unable to run this code because variables are undefined.
Okay i successfully reconstructed the results, but the probelm is when i directly use my data in AX =b form to reconstruct X , b is my data , then lsqlin doesnt reconstruct well. but when i scaled the data with maximum value in the data , by dividing this maximum value with data, also dividing this maximum value with upper and lower bound then it gives me good results and then i rescaled it by multiplying it with same maximum value ,Now i have concern why it is working good with scaled data and getting results with scaled data would be appropriate or not

Accedi per commentare.

Richiesto:

il 6 Set 2024

Commentato:

il 13 Set 2024

Community Treasure Hunt

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

Start Hunting!

Translated by