Error using surf plot

조회 수: 2 (최근 30일)
Jason
Jason 2016년 1월 18일
댓글: Jason 2016년 1월 18일
I have a vector of x and y coordinates of the red dots in the image below
I also have a vector of the FWHM at each of these points. I want to create a heat map where at each location x,y, the value if the fwhm and uses a color map.
I thought the following would work
surf(xf,yf,fwhm);
But I get the error
Error using surf (line 57)
Z must be a matrix, not a scalar or vector.
  댓글 수: 1
Jason
Jason 2016년 1월 18일
So I've tried the following:
k=zeros(length(xf),length(yf));
for i=1:length(xf)
k(xf(:,i),yf(:,i))=fwhm(:,i);
end
surf(xf,yf,k);
But now get
Subscripted assignment dimension mismatch.
Error in Merlion>pushbutton11_Callback (line 1920)
k(xf(:,i),yf(:,i))=fwhm(:,i);

댓글을 달려면 로그인하십시오.

채택된 답변

Thorsten
Thorsten 2016년 1월 18일
You can use
K = zeros(length(yf), length(xf)); % note that yf is first, xf is second because
% zeros use row, column indexing
ind = sub2ind(yf, xf); % ... same for sub2ind
K(ind) = fwhm;
imshow(K)
  댓글 수: 1
Jason
Jason 2016년 1월 18일
Thanks

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by