2D interp of matrix to heat map

5 views (last 30 days)
Wesley Gilliam
Wesley Gilliam on 11 May 2020
Commented: Wesley Gilliam on 18 May 2020
I have a 23x23 matrix with normalized values from a light source. The numbers indicate the measured intensity of the light source as a detector was moved in front of it along two axis, lets call it x and y axis. See the matrix attached below. I need to make a map of the intensity by interpolating in the rest of the matrix using only the data already in the matrix.
I believe interp2 is the right tool for the job but im a bit fuzzy on the best way to go about this. Any help and input would be very useful.
Attached below is an image of the matrix I have, and the type of map im hoping to get from the resulting matrix.
Thanks for any help!
Matrix
  2 Comments
Prasad Reddy
Prasad Reddy on 17 May 2020
please can you provide the actual matrix. not the immage formate. so that we can work on it and shall provide you the correct answer. Iam familear with heat maps. surely will help you.
Wesley Gilliam
Wesley Gilliam on 18 May 2020
Hello, It seems I may have worked it out, attached is a sample of the code I used. For simplicty I just replaced my actual data with ones as only the broad concept is what im going for. The xdata was replaced with "ones(1,25)" line 4 , and the ydata with "ones(1,25)" line 8. Run it and let me know if you know of a better way to do it.
Thanks, W
clear all;
% create 1D profile in X
profileX = ones(1,25).*fspecial('gaussian',[1 25],25);
figure; plot(profileX,'.');
% create 1D profile in Y
profileY = ones(1,25).*fspecial('gaussian',[1 25],20);
figure; plot(profileY,'.');
profileY = profileY';
clear profileXY;
% turn the 1D profile into a 2D matrix, so we can multiply them
profileX2D = repmat(profileX,25,1);
profileY2D = repmat(profileY,1,25);
% multiply element-by-element
profileXY = profileX2D.*profileY2D;
figure; imagesc(profileXY); axis image; colorbar;

Sign in to comment.

Answers (0)

Categories

Find more on Interpolation of 2-D Selections in 3-D Grids in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!