Skip to content

Instantly share code, notes, and snippets.

@michaelsilverstein
Last active November 6, 2017 23:53
Show Gist options
  • Save michaelsilverstein/e7227fd9b3c59d364762fc8b68b7e254 to your computer and use it in GitHub Desktop.
Save michaelsilverstein/e7227fd9b3c59d364762fc8b68b7e254 to your computer and use it in GitHub Desktop.
Generating parameter search space with vectorized formulation
%%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