Skip to content

Instantly share code, notes, and snippets.

@iveney
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iveney/24f93c1e89dc46fe3b89 to your computer and use it in GitHub Desktop.
Save iveney/24f93c1e89dc46fe3b89 to your computer and use it in GitHub Desktop.
Solutions to under-constrained linear system
>> rng(0)
>> A=randi(10, 2, 5); b=randi(100, 2, 1);
% A = b =
% 9 7 8 7 8 28
% 10 8 4 2 1 5
>> x1=A\b; x2=pinv(A)*b
% x1 = x2 =
% 0 1.5675
% 10.2500 6.1976
% 0 -3.8780
% 0 2.5279
% -0.4500 0.9060
>> b1=A*x1; b2=A*x2;
% b1 = b2 =
% 16.0000 16.0000
% 98.0000 98.0000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment