The text files contains Date&Time and some values. Please look in the attachments. I need to plot Second column with Date&Time. I see that the plot is random not as I needed. Here is the code I wrote:
fid = fopen(filename,'r');
Data = textscan(fid,'%s %s','Headerlines',1,'delimiter','\t');
fclose(fid);
DT = datenum(Data{1});
y = cellfun(@str2double,Data{2});
plot(DT,y,'-*');
datetick('x','dd.mm.yyyy HH:MM');
I cannot even see the right Date and Time on x axis. How can I make it clearly visible to the users? Is there any way to display xtick vertically?

 채택된 답변

Star Strider
Star Strider 2015년 1월 28일

0 개 추천

No attachments yet.
You can display the XTickLabel values vertically in R2014b using ordinary plot commands. In earlier versions, you have to use the text function with the 'XTick' property governing the positions of the values, then rotate them to whatever angle you need.

댓글 수: 4

pr
pr 2015년 1월 28일
Now I have attached the file. Sorry for that. I am using MATLAB 2012b.
This actually seems to read your data and plot appropriately:
fidi = fopen('pr_Test.txt','r');
D = textscan(fidi, '%s%s%f', 'Headerlines',1, 'CollectOutput',0)
DTs = [char(D{1}) repmat(' ', size(D{1})) char(D{2})];
DT = datenum(DTs, 'dd.mm.yyyy HH:MM:SS');
y = D{:,3};
plot(DT,y,'-*');
datetick('x','dd.mm.yyyy HH:MM');
Note my format string in my textscan call. I suspect that was part of the problem, since your format string failed to read your file properly in my code.
I leave it to you to experiment with the axis label formatting, but it seems reasonably appropriate to me. I will do my best to help you with it if you want to change it.
pr
pr 2015년 1월 28일
편집: pr 2015년 1월 28일
Thanks for the answer. I found a way to rotate the Xtick.
Star Strider
Star Strider 2015년 1월 28일
My pleasure!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Language Support에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

pr
2015년 1월 28일

댓글:

2015년 1월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by