Last active
November 13, 2016 19:20
-
-
Save Corwinpro/10d54789b3f04d214134875aec8d67d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [n,m] = size(A1); %size of matrix | |
| options = optimoptions('linprog','Algorithm','dual-simplex'); % setting dual-simplex for solver | |
| result1_L1 = linprog([zeros(m,1);ones(n,1)],[+A1,-eye(n);-A1,-eye(n)],[b1;-b1]); % solving L1 norm, see http://math.stackexchange.com/questions/81150/solving-ax-b-under-l-1-ax-b-minimization | |
| result1_L1_x = result1_L1(1:m); % result L1-norm X vector | |
| res1_L1_norm = norm(A1*result1_L1_x - b1, 1); %residuals L1 norm | |
| result1_Linf = linprog([zeros(m,1);ones(1,1)],[+A1,-ones(n,1);-A1,-ones(n,1)],[b1;-b1]); % solving Linf norm minimization | |
| result1_Linf_x = result1_L1inf(1:m); % result L1-norm X vector | |
| res1_Linf_norm = norm(A1*result1_Linf_x - b1, 1); %residuals Linf norm | |
| result1_L2 = linsolve(A1.' * A1, A1.' * b1); | |
| res1_L2 = norm(A1*result1_L2 - b1, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment