From: Barry on
I need to determine the minimum of each 12 consecutive in an array of 48 in simulink. So what i have is a feed in of an array (48x365) which is half hourly electricty cost data for each day. I need to get the time to start storing, over 6 hours which will be the minimum of 12 consecutive numbers in the array. Any ideas woud be great?

so (48x365) need to find lowest sum of 12 consecutive numbers.
From: ImageAnalyst on
On Aug 11, 11:24 am, "Barry " <barryoconne...(a)gmail.com> wrote:
> I need to determine the minimum of each 12 consecutive in an array of 48 in simulink. So what i have is a feed in of an array (48x365) which is half hourly electricty cost data for each day. I need to get the time to start storing, over 6 hours which will be the minimum of 12 consecutive numbers in the array. Any ideas woud be great?
>
> so (48x365) need to find lowest sum of 12 consecutive numbers.
-------------------------------------------------------------------------------------------------------
Did you look at all input and output arguments of the min() function?
From: Roger Stafford on
"Barry " <barryoconnell2(a)gmail.com> wrote in message <i3ufal$gbv$1(a)fred.mathworks.com>...
> I need to determine the minimum of each 12 consecutive in an array of 48 in simulink. So what i have is a feed in of an array (48x365) which is half hourly electricty cost data for each day. I need to get the time to start storing, over 6 hours which will be the minimum of 12 consecutive numbers in the array. Any ideas woud be great?
>
> so (48x365) need to find lowest sum of 12 consecutive numbers.
- - - - - - - - - -
Call the 48 by 365 data array D.

h = 12;
C = [zeros(1,size(D,2));cumsum(D,1)];
[S,K] = min(C(h+1:end,:)-C(1:end-h,:));

S is a 1 by 365 row vector of the minimum sum interval for each column and K contains the start index of that interval for each column.

Roger Stafford
From: Barry on
Thanks very much that was excellent really appreciate it.