Plot contour on similarity matrix

I need to plot the contour which looks like the image. The image shows the contour of the laplacian kernel (similarity matrix)
I need to plot such contour on my similarity matrx (nxn) ....lets say the similarity matrix is built from the eucledian distance....

回答 (1 件)

Star Strider
Star Strider 2020 年 4 月 28 日

0 投票

Use the surfc function.

6 件のコメント

Virtualkeeda
Virtualkeeda 2020 年 4 月 28 日
Thanks for the reply.
But the input argument of the function says: "The function plots the values in matrix Z as heights above a grid in the x-y plane defined by X and Y. The color of the surface varies according to the heights specified by Z."
I have Z as a similarity matrix on x and y. Can it be considerded as height? I doubt it.
Star Strider
Star Strider 2020 年 4 月 28 日
If the values of the matrix change, it can be considered a ‘height’. If they are all the same, it is a plane.
Virtualkeeda
Virtualkeeda 2020 年 4 月 30 日
SO i passed these commands:
x=rand(250,1)*16-8;
y=rand(250,1)*16-8;
xy=[x,y]
scatter(x,y)
I get this plot:
[X,Y] = meshgrid(x,y);
surfc(X,Y,Z)
colorbar
OUtput is:
WHICH IS NOT AT ALL similar to what I had asked or even shown at the website of surfc.
Here Z is my similarity matrix which looks like this:
Z is of same dimension as of X and Y.
Star Strider
Star Strider 2020 年 4 月 30 日
That does not look like the similarity matrix in the first image you posted.
I have no idea what the problem could be.
Virtualkeeda
Virtualkeeda 2020 年 4 月 30 日
That is indeed a similarity matrix (verified with properties) as you can see the diagonal element is 1 depicting the maximum similarity of 1 if element is same, rest are other similarities.
Do you have atleat idea about what Z constitues in surfc (X,Y,Z)? they used Z=peaks(X,Y). So what each value in the matrix Z says about X and Y?
Star Strider
Star Strider 2020 年 4 月 30 日
The ‘Z’ matrix is what you specify it to be. (Note that ‘X’ and ‘Y’ are not required for surfc. In their absence, those values are set to the indices of the respective dimensions.)

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeContour Plots についてさらに検索

タグ

質問済み:

2020 年 4 月 28 日

コメント済み:

2020 年 4 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by