Plotting Points at Specified Index Values

조회 수: 6 (최근 30일)
Articat 2020년 1월 16일
댓글: Articat 2020년 1월 17일
I have one matrix, A, that is a 1x137 that consists of all of maximum index values of another matrix, B, 137x145.
I am plotting B using "imagesc()" by defining a grid to plot it on like so:
imagesc((xGrid2(1,:,1)),permute(yGrid2(1,1,:), [3 1 2]),((B)))
xGrid2(1,:,1) is a 1x145 matrix that spans from -15.4 to 46.01, and permute(yGrid2(1,1,:), [3 1 2]) is a 137x1 matrix that spans from -4.582 to 53.42.
Now, I want to plot the maximum index values of A onto B but am not sure how to do this. I am able to perform this without defining a grid easily however I want to plot A and B on the defined grid above. If I plot them together without using a user defined grid and save the corresponding x and y values of where the index maximum values lie, I have to perform a scaling factor to correct the x and y coordinates to fit my defined grid.
Thus, how can I go about plotting the maximum index values on a defined grid AND THEN extract the corresponding x and y values of these maximums?
I can use "impixelinfo()" to extract the x and y at each point but that would involve hard coding the coordinates of each point, I would like it to be a bit more automated..
Thanks for the help.
  댓글 수: 1
Articat 2020년 1월 16일
By "index" I am referring to intensity values? I can alter these values from 0-1 by defining the "caxis([])" directly under the "imagesc(...)" call. I am not great at the Matlab lingo..

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

답변 (1개)

Spencer Chen
Spencer Chen 2020년 1월 16일
Let's separate your problem into 2 parts: (1) Plotting problem. (2) Finding location of you Maximum on the xGrid2.
I'll start with (2). If you have not used the max() function to extract your maximums, then you read up a little more on it -- it will give you the indices of your maximum value:
[A,IB] = max(B,[],2);
xA = xGrid2(1,IB,1);
I believe xA should give you the coordinates that you want to get.
Now, as for (1) plotting, you can hold the axis and use plot() or scatter():
hold on
plot(xGrid2(1,IB,1), squeeze(yGrid2(1,1,IB)), '.')
hold off
Note the use of the squeeze() function. It should replace your permute() operations.
(Code not tested...)
  댓글 수: 1
Articat 2020년 1월 17일
[A,IB] = max(B,[],2);
xA = xGrid2(1,IB,1);
Extracts the appropriate x-values fantastically. When I tried the plotting code the result is a constant value. I tried doing the same to extract the y-values but I get a different sized matrix. I did the following:
[A_2, IB_2] = max(jet_rot, [], 1);
I guess what is happening is I am selecting the max intensity matrix values coming from another direction. What I mean is the maximum values of A are the not the same as A_2 when they should be if I want to obtain the correct x and y coords.
Is there a way I can do the same thing for IB as for IB_2??
Thanks for your help.

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


Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by