필터 지우기
필터 지우기

How to plot timeseries graph

조회 수: 1 (최근 30일)
emily bristow
emily bristow 2020년 11월 30일
답변: Mathieu NOE 2020년 12월 8일
I have 7 months of dissolved oxygen data through a water column (March, April, May, June, July, August, November) I need to plot this as a timeseries but I'm unsure on where to start.
How do I plot the bottom water oxygen concnetrations against each month they were taken?
The excel file attatched is one example of the data.
  댓글 수: 1
Mathieu NOE
Mathieu NOE 2020년 12월 8일
hello
how are the data sampled ? I assume the attached xlsx file does not cover the entire 7 monthes ?
you want to plot each seperate month (one plot = one month ? )

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

답변 (1개)

Mathieu NOE
Mathieu NOE 2020년 12월 8일
hello again
a sample code that can help you
% data format (7 columns)
% depth temp salin sig chl DO DO%
% -5 9,491 35,311 27,281 0,59 285,5 100,31
% assuming one data = one day
% how many days in each month :
% March : 31 , April : 30 , May : 31 , June : 30 , July : 31, August : 31 , November : 30
monthes = {'March','April','May','June','July','August','November'};
days_per_month = [31 30 31 30 31 31 30];
filename = "mar2014ctd2.xlsx"; % extended data length to cover the 7 month / 1 data per day range
C = readcell(filename);
[m,n] = size(C);
data = cell2mat(C(2:m,:)); % start at row index 2 to ignore header line
stop_index = 1; % init
%% plot
for ci = 1: length(days_per_month)
start_index = stop_index;
stop_index = start_index-1 + days_per_month(ci);
x_axis = 1:1:days_per_month(ci);
DO_extract = data(start_index:stop_index,6); % 6th column = DO
figure(ci), plot(x_axis,DO_extract,'*-');grid
title(monthes(ci));
xlabel('Days');
ylabel('DO');
end

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by