Last active
November 6, 2017 23:53
-
-
Save michaelsilverstein/e7227fd9b3c59d364762fc8b68b7e254 to your computer and use it in GitHub Desktop.
Generating parameter search space with vectorized formulation
This file contains 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
%%Search parameter space | |
[xx,yy] = meshgrid([-5:.1:9],[-5:.1:9]); | |
% Calculate residual for every pair of parameters | |
%Setup matrix where each row is a single set of parameters | |
X = [xx(:),yy(:)]; | |
%Calculate residual of each pair of guesses of parameters | |
res = b-A*X'; | |
r = []; | |
%Calculate norm^2 of residuals from each guess | |
for i = 1:length(res) | |
r = [r norm(res(:,i))^2]; | |
end | |
%Reshape back to 2D | |
phi = reshape(r,size(xx)); | |
%Plot | |
figure | |
contour(xx,yy,phi,'ShowText','on') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment