필터 지우기
필터 지우기

Plot matrix with imagesc

조회 수: 7 (최근 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 CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by