![]() |
Matlab x轴上的日期和时间
我有一个txt文件
20100318,1630,17.3600,17.3700,17.2900,17.3000,150408 20100318,1700,17.3000,17.3200,17.2700,17.3200,69629 20100318,1730,17.3100,17.3100,17.3100,17.3200,0 20100319,900,17.4000,17.5600,17.3500,17.5100,460691 20100319,930,17.5100,17.5400,17.4200,17.4200,143917 其中第一和第二列是日期和时间,以逗号作为列分隔符。 我希望x和ax上的日期和时间在1730(每天的最后一条记录)和900(第二天的第一条记录)之间没有空格。 [B]回答:[/B] 这是执行此操作的一种方法(假设txt文件称为“ test.txt”): data = csvread('test.txt'); %# read the txt file plot(data(:,6)); %# plot the data date = num2str(data(:,1)); %# read date time = num2str(data(:,2)); %# read time dt = [date,repmat(' ',size(data,1),1),time]; %# combine date and time set(gca,'xtick',1:size(data,1),'xticklabel',dt) %# set axes labels 请注意,创建日期-时间字符串的方法[URL="http://www.mathworks.com/matlabcentral/fileexchange/8722-rotate-tick-label"]更为简便[/URL] ,并且您可能对使用文件交换中的[URL="http://www.mathworks.com/matlabcentral/fileexchange/8722-rotate-tick-label"]ROTATETICKLABELS[/URL]感兴趣,以便更好地了解日期和时间。 [url=https://stackoverflow.com/questions/3618577]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 01:07。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.