[Scilab-users] add number arrays efficiently, how?

Pablo Fonovich pablo_f_7 at hotmail.com
Fri Mar 24 02:01:49 CET 2017


Hi,
I would have also written

SumArr = [SumArr toAdd]

Why is this answer different to the original?

SumArr( (length(SumArr)+1) : (length(SumArr)+length(toAdd)) ) = toAdd;

May be im missing something, but i think in both cases you need to know the arrays in advance, dont you?

Also, i think  SumArr = [SumArr toAdd] has better performance...
Perhaps im not understanding the question..

Obtener Outlook para Android<https://aka.ms/ghei36>


________________________________
From: users <users-bounces at lists.scilab.org> on behalf of Tim Wescott <tim at wescottdesign.com>
Sent: Wednesday, March 22, 2017 8:50:26 PM
To: Users mailing list for Scilab
Subject: Re: [Scilab-users] add number arrays efficiently, how?

On Thu, 2017-03-23 at 00:28 +0100, Samuel Gougeon wrote:
> Le 22/03/2017 à 23:15, Erhy a écrit :
> >
> > 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?
> SumArr = [SumArr toAdd]
>

If you know them in advance, yes.  My answer was predicated on not
knowing "toAdd" at the same time as the 1x3 SumArr.

> --

Tim Wescott
www.wescottdesign.com<http://www.wescottdesign.com>
Control & Communications systems, circuit & software design.
Phone: 503.631.7815
Cell:  503.349.8432



_______________________________________________
users mailing list
users at lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170324/ecd28e72/attachment.htm>


More information about the users mailing list