| MATLAB Central > MATLAB Newsreader > Is it Ok to shrink with [ ]? |
|
|
|
Dear all, |
|
It would appear so: |
|
"Andy " <myfakeemailaddress@gmail.com> wrote in message <i43df8$ba6$1@fred.mathworks.com>... |
|
> You also have to be careful with a for loop since the total length may not be as long at the end (after removing spots) when it was when you initialized the loop. |
|
"Andy " <myfakeemailaddress@gmail.com> wrote in message <i43hvm$rc0$1@fred.mathworks.com>... |
|
"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i43itl$r5n$1@fred.mathworks.com>... |
|
"Akim " <aaa@bbb.ccc> wrote in message <i43bor$n7h$1@fred.mathworks.com>... |
|
Sean, I see your point. Since the while loop recalculates length(x) on each loop iteration, you won't accidentally index outside the bounds of x. I would argue, however, that both of these loops are quite dangerous in that they present a silent error: it seems the intent is to eliminate every 100th element of x. But of course this is not what either loop does. |
|
Thanks all for your help. |
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.
| Tag Activity for This Thread | ||
|---|---|---|
| Tag | Applied By | Date/Time |
| memory | Akim | 13 Aug, 2010 07:59:05 |
| shrink | Akim | 13 Aug, 2010 07:59:04 |
