On Wed, 2017-03-22 at 15:15 -0700, Erhy wrote: > Hello! > I'm thinking in arrays - and I write > > SumArr = [ 1 2 3 ]; toAdd = [ 7 8 9 10 ]; > SumArr( (length(SumArr)+1) : (length(SumArr)+length(toAdd)) ) = > toAdd; > > How to code it smarter?
That's probably the best way to append an array if you can't anticipate ahead of time how big your ending array will be. However, each time you do that Scilab has to allocate space for a bigger array, copy, and destroy the old copy of the array. If you DO know how big your ending array will be, then you can speed things up by creating a zero array of full size, then populating it as you go. I.e., in this case you'd create SumArr to be 1x7, then populate the first three elements, then populate the last four. -- Tim Wescott www.wescottdesign.com Control & Communications systems, circuit & software design. Phone: 503.631.7815 Cell: 503.349.8432 _______________________________________________ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users