Plot matrix with imagesc

9 ビュー (過去 30 日間)
aurc89
aurc89 2020 年 3 月 31 日
コメント済み: aurc89 2020 年 3 月 31 日
I have a question concerning the plot with imagesc. I have a variable a which is a struct, made of data and the first line of letters (each letter denotes a column), as shown in the figure on the left.
To plot this, I extract the data from the struct a (dat=a.data) and I use the function imagesc (imagesc(dat)), obtaining the figure on the rigth.
I would like to add the letters as shown in the figure (A,B,C), in order to label the data. These letters should be read directly from the line of the .txt file.
How can I do this?

採用された回答

Mehmed Saad
Mehmed Saad 2020 年 3 月 31 日
編集済み: Mehmed Saad 2020 年 3 月 31 日
  • Use text scan to read from text file
  • Use text to write text on figure
no_of_word_to_read = 3; %no of columns
filename = 'C:\Users\XX PC\Desktop\x.txt'; % your own file name with path
fileID = fopen(filename,'r');%open txt file
varn = textscan(fileID,'%s',no_of_word_to_read);%read text from it
fclose(fileID);% close txt file
v = figure;
imagesc(dat)
mina= min(v.Children.YLim)%get the axis limit
for i = 1:no_of_word_to_read
text(i,mina-0.1,varn{1}{i},'FontSize',15);
end
  3 件のコメント
Mehmed Saad
Mehmed Saad 2020 年 3 月 31 日
mina= min(ylim)
aurc89
aurc89 2020 年 3 月 31 日
It works! Thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeBar Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by