Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: vectorization speed
Date: Mon, 7 Oct 2013 06:31:05 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 13
Message-ID: <l2tkf9$9hl$1@newscl01ah.mathworks.com>
References: <bb7943ed-370c-4c27-9781-585085c9444f@googlegroups.com> <l2rrfl$7aj$1@speranza.aioe.org>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: rubyext-04-ls.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1381127465 9781 172.20.102.180 (7 Oct 2013 06:31:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 7 Oct 2013 06:31:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:803381

> 
> function res=scale(x)
>    res=0.1*x;
>    res(res<0)=0;
>    res=min(res,1);
> end
> 

Not sure about speed, it can be achieve by single line (do we need a function for that ?)

res = max(min(0.1*x, 1), 0)

Bruno