|
|
 | | Re: NBC arrays
|
| Thank you for the valuable first-hand information. It is a pitty there is no byte-code instruction to copy a part of an array somewhere to a middle of another array (so that one does not have to index and replace element-by-element or allocate a new (...) (19 years ago, 13-May-07, to lugnet.robotics.nxt)
| | |  | | Re: circular pointer
|
| In lugnet.robotics, linmix <linmix@gmail.com> wrote: [snip] (...) [snip] I would say defining SIZE changes the size of the array and thus the period of the moving average. I'm not sure how you mean "macro" in this context. [snip] (...) Yes, both (...) (19 years ago, 13-May-07, to lugnet.robotics)
| | |  | | Re: circular pointer
|
| I've inserted some comments, not all are questions, some are simply 'thinking aloud'. (...) So by defining SIZE here I can easily change the size of the macro without having to alter anything else in the code. Nice! (...) Right you are, I should (...) (19 years ago, 13-May-07, to lugnet.robotics)
| | |  | | Re: circular pointer
|
| I've added my comments to the code you posted (they start with **). I've also added some indenting.: #define SIZE 3 int v[SIZE],i,sum,ave; // initialize the array and some other variables sum = 0; for (i=0;i<SIZE-1;i++) { //I think this means set (...) (19 years ago, 13-May-07, to lugnet.robotics)
| | |  | | Re: circular pointer
|
| (...) The line above is the line that cycles the array - each time through the loop it increments i and resets it to zero if it's >= SIZE (% is modulus operator). But I would agree with you about the v[i]=0 line - seems to me it would make the (...) (19 years ago, 12-May-07, to lugnet.robotics)
| |