change calculation into financial/fiscal year

4 views (last 30 days)
NMans on 25 Jun 2018
Edited: dpb on 30 Jun 2018
I've been doing my calculations/written my code based on calendar year, but realised now that I should have done it based on financial year i.e. 1st April to 31st March. Is there an simpler way to do this without having to change a lot of the lines. To simplify, say I have 2 matrices:
Power = [year month day hour data1]
Speed = [year month day hour data2]
I've changed the year month day into timestamp using datenum and match the timestamp of Power and Speed to give a relative magnitude of wind speed to power:
Power curve = [year month data2 data1]
In a lot of my subsequent calculations, I've done a lot of loops based on calendar year using 'unique year' and therefore it would be a pain to change a lot of that. Just to give you an idea, I have hourly Power data for 17 power stations, each with varying year of operations, and hourly speed data from 1985-2018.
So my question is, is there a way to manipulate my initial data (Power and Speed) so that the 'unique year' corresponds to 1st April to 31st March, rather than 1st Jan to 31st Dec?
dpb on 28 Jun 2018
We're fortunate that they are still (at least so far) on the far horizon but they're some of the newer monsters and it's almost 60 mi away and they're still on the horizon from the second floor window.
I can't imagine the problem when they're right in the neighborhood, especially if it's your neighbor getting the royalty check and all you have is the noise and visual pollution.
It's one of these things that is much better in theory and for some than others in practice.

Sign in to comment.

Accepted Answer

dpb on 26 Jun 2018
Edited: dpb on 26 Jun 2018
Actually, it's pretty simple to accomplish. Given the year and month vectors, create a "financial year" by
yrFin=yr; % initialize to existing year
ix=(mo<4); % logical index to Jan-Mar
yrFin(ix)=yr(ix)-1; % belongs to previous financial year
I would still recommend looking seriously at datetime instead of datenum and in particular then investigate the use splitarray, varfun and findgroups to simplify the computations by groups where here for starters the grouping variable would by yrFin
Also NB: that the names year, month, etc., are Matlab builtin functions used with datetime class so I've not used those as variables.
dpb on 28 Jun 2018
Having hard time envisioning what wouldn't still be the correct analysis year; by your definition anything in the first Q is the previous year.
Show an example that you think is a problem...
Or, of course, you could alternatively define the analysis year to be the same as the actual year of the Q1 dates in which case the remainder is in the next analysis year and then one would write that
yrFin=yr; % initialize to existing year
ix=(mo>3); % logical index to Jan-Mar
It's totally arbitrary as to which you choose.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!