Path: news.mathworks.com!not-for-mail
From: "Stefan " <aidematlab@yahoo.ca>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Avoiding for loop
Date: Sun, 25 Jul 2010 11:19:04 +0000 (UTC)
Organization: McGill University
Lines: 16
Message-ID: <i2h6j8$659$1@fred.mathworks.com>
References: <i2cpf0$j3k$1@fred.mathworks.com> <i2cqal$ra0$1@canopus.cc.umanitoba.ca> <i2cr4t$7oq$1@fred.mathworks.com> <i2crpp$jcj$1@fred.mathworks.com> <i2csjm$b49$1@fred.mathworks.com> <i2cuqt$tc$1@fred.mathworks.com>
Reply-To: "Stefan " <aidematlab@yahoo.ca>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1280056744 6313 172.30.248.38 (25 Jul 2010 11:19:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 25 Jul 2010 11:19:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2343684
Xref: news.mathworks.com comp.soft-sys.matlab:655924

Thx for the solution without the for loops.
The bigger picture is that there is a second function V2, with matrices A2 & B2.
I'm trying to find all the points (x1,x2,x3,x4) where V<V2, and x1,x2,x3,x4 are changing by a 0.1 stepsize.

> I'm willing to lay odds that you don't need this and that it would be advisable for you to explain the bigger picture of what you're trying to do. 
> 
> Just for fun, though, the for-loops can be eliminated from Andy's solution as follows:
> 
> [x1,x2]=ndgrid(-10:0.1:10, -10:0.1:10);
> 
> XX=[x1(:).';x2(:).'];
> 
> tmp1 = sum( XX.*(A*XX) );
> tmp2 = XX'*expm(B);
> 
> V=bsxfun(@plus, tmp1, tmp2*XX);