필터 지우기
필터 지우기

Hallo, ich möchte den Wasserstand gegen Datum darstellen. Ich habe aber Problem mit der Darstellung des Datums bei x-achse! Ich danke euch für die Hilfe im Voraus.

조회 수: 6 (최근 30일)
%plot water level
%% water level data
clear all
close all
fid = fopen('/Umweltdaten/Wasserstand/TuemlauAP_Herbst2017.txt'); %Dateiname for Water level
data = textscan(fid,'%s %f');
fclose(fid);
water_le = data{2};
% water_le(water_le==-999) = NaN;
for i = 1 : length(data{1}) % creat non-linear time-vector.
time(i) = datenum(sprintf('%s',string(data{1}(i))),'yyyymmddHHMMSS');
end
xticks = datenum('2017-09-07T00:00:00.0000','yyyy-mm-ddTHH:MM:SS.FFFZ'):1:datenum('2017-10-13T00:00:00.0000','yyyy-mm-ddTHH:MM:SS.FFFZ');
labels = datestr(xticks,'dd.mm');
figure
plot(time,water_le,'k','LineWidth',2);
%xlabel('time [h]')
ylabel('Water level')
xlim([min(time) max(time)])
%ylim([180 540])
set(gca,'XTick',xticks,'XTickLabel',labels);
  댓글 수: 5
Faisal Tawashi
Faisal Tawashi 2023년 11월 28일
_The Version is R2023b.
_If I want to represent date, the scalar does not start at zero and the values of the date end approximately in the centre of the axis. Water level is raised every minute in the text file.
_The expected output on the X axis is the date from 07.09.2017 until the date 13.10.2017

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

채택된 답변

Harald
Harald 2023년 11월 29일
Hallo,
mit datetime lassen sich Datumsangaben viel schöner plotten:
time = datetime(data{1}, "InputFormat", "yyyyMMddhhmmss");
Die Daten beginnen bereits Ende August und enden Mitte November. Wenn du nur einen Ausschnitt der Daten haben möchtest, kannst du im Live Editor interaktiv zoomen oder das mit xlim angeben, dann aber mit Datumsangaben:
xlim([datetime(2017, 9, 7), datetime(2017, 10, 13)])
Viele Grüße,
Harald

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!