# How to split monthly value into days

2 visualizzazioni (ultimi 30 giorni)
Jan Koncel il 27 Mar 2022
Commentato: Jan Koncel il 28 Mar 2022
Hello everyone
I have a little issue here. Solution must be easy, but i cant figure it out.
I have 12 values (each represent ideal rain in every month) IR = [0 0 0 70 83 100 110 100 70 0 0 0]'
Then i have long datetime (10 years) with daily time step.
Need to find out value for each day.
Example: IR for 27.Sept = IR(Sept)/number of days in Sept
Thanks for every help
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Andrei Bobrov il 27 Mar 2022
Let dates - your long datetime (10 years) with daily time step.
out = IR(month(dates))./day(dates,"dayofmonth")
##### 2 CommentiMostra NessunoNascondi Nessuno
Jan Koncel il 27 Mar 2022
Thank you very much for your answer. It almost works, but i dont want to divide it by number of day in month. For example: Since April has 30 days and IR for April is 70, I want to have value 70/30 on every day in April. Now it gives me for 1.Apr 70/1, for 2.Apr 70/2...
Jan Koncel il 28 Mar 2022
I found way it works out for me, your advice was very useful, thanks
IR = [0 0 0 70 83 100 110 100 70 0 0 0]';
days_in_month = days(dateshift(Date,'end','month')-dateshift(Date,'start','month')+1);
IR_d = IR(month(Date))./days_in_month;

Accedi per commentare.

### Categorie

Scopri di più su Language Fundamentals in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by