Path: news.mathworks.com!newsfeed-00.mathworks.com!newscon02.news.prodigy.net!prodigy.net!news.glorb.com!news.aset.psu.edu!news.cse.psu.edu!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Newsgroups: comp.soft-sys.matlab
Subject: Re: Find Minimum
Date: Mon, 11 Feb 2008 22:53:14 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 31
Message-ID: <foqjkq$prp$1@canopus.cc.umanitoba.ca>
References: <ac460e51-a1a5-4e93-9031-220be5a23e5a@f10g2000hsf.googlegroups.com> <Xns9A419D4C96F57scottseidmanmindspri@130.133.1.4> <foqcnc$i3l$1@canopus.cc.umanitoba.ca> <59c7a60a-4c16-401e-a6a2-4a1cb1901c3d@z17g2000hsg.googlegroups.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1202770394 26489 192.70.172.160 (11 Feb 2008 22:53:14 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Mon, 11 Feb 2008 22:53:14 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:450685


In article <59c7a60a-4c16-401e-a6a2-4a1cb1901c3d@z17g2000hsg.googlegroups.com>,
shapper  <mdmoura@gmail.com> wrote:

>Evaluate my function at all 4,000,000? Now I am scared ... :-)

>  How could I create such a script that would make it possible for me
>to evaluate all the solutions.
>  I need a flexible approach because MyFun can have 3 or MORE inputs
>with their constraints.
>  It would be great if I could use this in different functions.


If the parameters can be described by a list of discrete values,
especially ones at regular intervals, then you can put the
parameter value lists into a cell, construct an empty cell
of the right size to receive the arguments, and then use ndgrid.

>> bar = {1:3 2:5 8:11};foo = cell(1,length(bar)); [foo{:}] = ndgrid(bar{:})

foo = 

    [3x4x4 double]    [3x4x4 double]    [3x4x4 double]

Then provided that MyFun has been written to accept vectorized
inputs, myFun(foo{:})


Wouldn't necessarily be fast, though!
-- 
  "There is nothing so bad but it can masquerade as moral."
                                              -- Walter Lippmann