help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Combining Vectors


From: John W. Eaton
Subject: Re: Combining Vectors
Date: Tue, 19 Apr 2011 09:03:03 -0400

On 18-Apr-2011, stn wrote:

| 
| 
| 2011/4/18 GFotios <address@hidden>
| 
| 
|     On Apr 18, 2011, at 11:11 AM, stn wrote:
| 
| 
| 
| 
|     [v1,v2] = meshgrid ([1;2;3],[4;5;6])
| 
|     and then
| 
|     [v1(:),v2(:)]
| 
|     is what you want. Or
| 
|     v1 = repmat([1;2;3],1,3).'(:)
|     v2 = repmat([4;5;6],1,3)(:)
|     [v1, v2]
| 
|     Enjoy,
|     /Fotis
| 
| 
| Yes, thank you.
| Both methods work. With meshgrid it is even possible to combine 3 vectors:
| 
| [v1,v2,v3] = meshgrid ([1;2;3],[4;5;6],[7 8 9]) ;
| [v1(:),v2(:),v3(:)]
| 
| Can this also be done with an abitrary number of vectors ?

The method in the following message can be expanded to more
dimensions:

https://mailman.cae.wisc.edu/pipermail/help-octave/2011-April/045415.html

| The idea is to generate input-data for a simulation which is
| supposed to run an existing model with every conceivable combination
| of input-data. It would then calculate statistics, distribution
| etc. The number of input-variables is 6 to 8, with 5 values per variable.

For 8 dimensions and the same number of values for each dimension, you
are going to need N^8*8 bytes of memory to store the set of inputs.
So it's good that you only have 5 different values and not 1000 or
so...

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]