Borrar filtros
Borrar filtros

Data extraction of dates

1 visualización (últimos 30 días)
Asanka Subasinghe
Asanka Subasinghe el 24 de Mzo. de 2020
Comentada: Walter Roberson el 25 de Mzo. de 2020
I have a column of data with rainfall on each day, from 2004 to 2016. I want to be able to extract the rainfall data for each day and store that data into columns of months for each year. I have created a loop that finds the end day of all months from 2004 to 2016, but am having trouble now extracting the information.
[SL: formatted question as text not code]
  2 comentarios
Mohammad Sami
Mohammad Sami el 24 de Mzo. de 2020
Editada: Mohammad Sami el 24 de Mzo. de 2020
Create a vector to store the index of the days (rows) you want to extract. Then you can simply subset.
Asanka Subasinghe
Asanka Subasinghe el 24 de Mzo. de 2020
I need some sort of loop because theres more than 4000 data points

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 24 de Mzo. de 2020
Editada: Walter Roberson el 24 de Mzo. de 2020
Dv = Dates(:) ;
Output = accumarray([day(Dv), month(Dv), year(Dv)-2003], Rainfall(:), [31 12 13], [], nan);
The result will be a 3d array with one pane for each year, with rows being day numbers, columns being month numbers. Unused entries such as shorter months or missing data will be set to nan
  6 comentarios
Asanka Subasinghe
Asanka Subasinghe el 25 de Mzo. de 2020
clc;clear all;close all
filename='Data Q2 (2).xlsx';
data=(readtable(filename))
dandenongnum=data(:,2);
dandenongdate=data(:,1);
Dv=dandenongdate;
Output = accumarray([day(Dv), month(Dv), year(Dv)-2003], dandenongnum, [31 12 13], [], nan);
Walter Roberson
Walter Roberson el 25 de Mzo. de 2020
clc;clear all;close all
filename='Data Q2 (2).xlsx';
data=(readtable(filename))
dandenongnum=data{:,2};
dandenongdate=data{:,1};
Dv=dandenongdate;
Output = accumarray([day(Dv), month(Dv), year(Dv)-2003], dandenongnum, [31 12 13], [], nan);

Iniciar sesión para comentar.

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by