キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

Decimate 1D Array

解決済み
解決策を見る

Say I have an array of 500 elements and would like to perform analysis on every 10 elements i.e. perform analysis on elemens 0-9, then on 10-19, then on 20-29 etc. etc. what would be the best way about doing this.

 

I was thinking about splitting up the array into a number of subarray's but the decimate 1D array function doesn't maintain the order of the elements in the original array. Is there any other function that can be used to achieve this?

 

I understand I could use a loop of some sort to iterate through the array and perform analysis every 10 elements but the array could be quite large and I want to do this as efficiently as possible.

 

Any ideas?

 

Strokes

0 件の賞賛
メッセージ1/6
7,688件の閲覧回数

The Array Subset in a loop is probably best.  This does not change the allocation of memory for the main array and only allocates one 10-element subarray space which can be reused.

 

Do you ever need the entire array later for something else or do you just use the subsets? Do you need more than one subset at a time? A complete description of what you are trying to do would help us give you good answers.

 

Lynn

メッセージ2/6
7,684件の閲覧回数

 


@johnsold wrote:

The Array Subset in a loop is probably best.  This does not change the allocation of memory for the main array and only allocates one 10-element subarray space which can be reused.

 

Do you ever need the entire array later for something else or do you just use the subsets? Do you need more than one subset at a time? A complete description of what you are trying to do would help us give you good answers.

 

Lynn


I don't necessarily need the entire array later but it might be nice to have if I want to plot the data. No i'll never need more than one subset at a time.

 

My objective is simple enough, I'll stream parsed data from a device into an array. When the data stops streaming, i'll have an array of however many values depending how long the data is streaming for. I'll then analyze a certain subset of the array maybe 10, 15 or 20 elements at a time.

 

I think what you've described above is a solution, it's certainly something i'll experiment with anyways so thanks for that.

 

Strokes

0 件の賞賛
メッセージ3/6
7,677件の閲覧回数
メッセージ4/6
7,672件の閲覧回数

@Amd1480 wrote:

Check this out


thanks man, looks perfect.

 

Strokes

0 件の賞賛
メッセージ5/6
7,654件の閲覧回数
解決策
トピック作成者Strokesが受理

@Amd1480 wrote:

Check this out


I have the feeling that the constant resizing of the array inside the shift register might cause more memory allocation that you would like.

 

I would recommend a simple "reshape array" or "array subset" as has already been suggested. Here are the two alternatives.

 

If the array size in not divisible by the subeset size, these example will ignore the incomplete tail. (It would be a trivial change to instead process it.)

 

 

すべてをダウンロード
メッセージ6/6
7,645件の閲覧回数