Highlighting a portion of an image created from a matrix using "pcolor"

I have created an image to visualize a matrix I have using pcolor function. The plot is shown below. I want to highlight elements of the matrix located in the range [65 95] using a square frame or anything else. I have created a square around this area manually but it is not perfect. Any idea?
Thanks
xx.png

 採用された回答

Walter Roberson
Walter Roberson 2019 年 3 月 4 日

1 投票

  • You can use rectangle() to draw on the display.
  • You can use the Computer Vision function insertShape() to write into an array (probably displaying the array later)
  • You can use assignment statements to write into an array (probably displaying the array later)
xloc = 65:95;
yloc = 65:100;
YourArray(yloc, xloc([1 end]), :) = 255; %left and right edges
YourArray(yloc([1 end]), xloc, :) = 255; %top and bottom edges

4 件のコメント

Ismaeel
Ismaeel 2019 年 3 月 4 日
編集済み: Ismaeel 2019 年 3 月 4 日
Thank you so much Walter Roberson; The code you attached works perfectly, and the result is ploted below.
Would it be okey if I ask another related question? How can I label the axes individually or in groups on both axes?
Thank you
Untitled.png
Walter Roberson
Walter Roberson 2019 年 3 月 4 日
xlabel('x'); ylabel('y')
When you start talking about labeling in groups, I wonder if you are talking about the tick labels ?
Ismaeel
Ismaeel 2019 年 3 月 4 日
So, the matrix I have is of [176 176] dimension.I wanted to label both axes with their corresponding row and column number; that is, from 1 to 176 on both axes. Or, if the labels are so dense and can't be read, I wonder if I can divide the labels into groups.
Ismaeel
Ismaeel 2019 年 3 月 4 日
編集済み: Ismaeel 2019 年 3 月 4 日
Thanks Walter Roberson once again; I have solved the legend problem using the "xticks, xticklabels, xtickangle" functions you referred to.

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

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2019 年 3 月 4 日

編集済み:

2019 年 3 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by