Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Get minimum of the sum of 12 consecutive numbers in an array of 48

Subject: Get minimum of the sum of 12 consecutive numbers in an array of 48

From: Barry

Date: 11 Aug, 2010 15:24:05

Message: 1 of 3

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.

Subject: Get minimum of the sum of 12 consecutive numbers in an array of 48

From: Roger Stafford

Date: 12 Aug, 2010 01:07:05

Message: 2 of 3

"Barry " <barryoconnell2@gmail.com> wrote in message <i3ufal$gbv$1@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

Subject: Get minimum of the sum of 12 consecutive numbers in an array of 48

From: Barry

Date: 12 Aug, 2010 17:32:20

Message: 3 of 3

Thanks very much that was excellent really appreciate it.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us