2017-11-05 17 views
0

Matlabのnetcdfファイルからデータをプロットしていますが、x軸はUTC秒であると考えられます。プロット後、私はそれをHH:MM:SS形式に変更する方法を理解できないようです。 this is an example as you can see on the x-axis of what is happening は、私のような別のものを試してみました:Matlabで秒をUTCに変更する

time=datenum(x,'HH:MM:SS') 

が、彼らは動作しません。 ここに私がしようとしているもののより良い例があります:このフライトのデータは2010年9月10日に撮影され、データは「秒から開始して09:00:00」に記録され、ここにコード:

%time 
x = double(netcdf.getVar(ncid,netcdf.inqVarID(ncid,'Time'))); 
%altitude 
y_alt = double(netcdf.getVar(ncid,netcdf.inqVarID(ncid,'GGALT'))); 
%temperature 
y_t = double(netcdf.getVar(ncid,netcdf.inqVarID(ncid,'ATX'))); 
%dew point 
y_dp = double(netcdf.getVar(ncid,netcdf.inqVarID(ncid,'DPXC'))); 
%vertical wind speed 
y_vws = double(netcdf.getVar(ncid,netcdf.inqVarID(ncid,'WIC'))); 
%horizontal wind speed 
y_hws = double(netcdf.getVar(ncid,netcdf.inqVarID(ncid,'WSC'))); 
%liquid water content 
y_lwc = double(netcdf.getVar(ncid,netcdf.inqVarID(ncid,'PLWCC'))); 
%ice water content 
y_iwc = double(netcdf.getVar(ncid,netcdf.inqVarID(ncid,'PLWC1DC_LMI'))); 

figure 
plot(x,y_alt, 'r') 
ylim([0 15000]) 
title({'Altitude vs Time RF14'}, 'fontweight', 'bold', 'fontsize', 12); 
xlabel('UTC (seconds)'); 
ylabel('Altitude (meters)'); 

figure 
plot(x,y_t,'b',x,y_dp,'r') 
ylim([-100 50]) 
title({'Temperature and Dew Point RF14'}, 'fontweight', 'bold', 'fontsize', 12); 
xlabel('UTC (seconds)'); 
ylabel('Temperature (C)'); 
legend('Temperature', 'Dew Point'); 

figure 
plot(x,y_vws,'b',x,y_hws, 'm') 
ylim([-5 11]) 
xlim([0 20500]) 
title({'Wind Speed RF14'}, 'fontweight', 'bold', 'fontsize', 12); 
xlabel('UTC (seconds)'); 
ylabel('Wind Speed (m/s)'); 
legend('Vertical Wind Speed', 'Horizontal Wind Speed'); 

figure 
plot(x,y_lwc, 'm',x,y_iwc,'b') 
ylim([-1 11]) 
title({'Liquid/Ice Water Content RF14'}, 'fontweight', 'bold', 'fontsize', 12); 
xlabel('UTC (seconds)'); 
ylabel('H2O Content (g/m^3)'); 
legend('Liquid Water Content', 'Ice Water Content'); 

したがって、秒の範囲は0〜19920です。 2010年9月10日09:00:00から2010年9月10日15:32:00に終了したいと思います。何らかの理由で私はデータのことを私のために働かせることができません。

+0

https://au.mathworks.com/matlabcentral/answers/6117-convert-date-to-unix-time?requestedDomain=www.mathworksです。 com – marekful

答えて

0

あなたX - 軸の変数は秒である場合、86400による最初の除算は、1日の単位に変換し、その後、希望の日付形式でdatetickを適用します。ここで

は例

x = 0:10:34e3; % x axis in seconds 
y = cumsum(randn(size(x))); % example y values 
plot(x/86400, y) % plot with x in days, not in seconds 
datetick('x', 'HH:MM:SS') % set date ticks in x axis 
grid on % optionally add grid 

enter image description here

+0

まだ私はそれを働かせることができないので少しの助けを得るために少し質問を更新しました。ここまでのご協力ありがとうございました –

+0

基本的には、真夜中から午前9時(UTC –

+0

@ h.k)までの秒数を追加するだけでした。すばらしいです!あなたの更新された質問をすばやく見て、あなたが望んでいたことを理解していませんでした –

関連する問題