# probably a simple problem....

• May 1st 2009, 09:19 AM
canopy
probably a simple problem....
Ok, so I'm not a programmer by any means, I'm a geologist - truth be told. I'm working on a melting model of the mantle and don't normally have to get too in depth with my MATLAB scripts.

I've been trying to use this function fmincon to find a minimum value for this function, but its not outputting believable answers. So I've decided to see if its possible to just brute force find a solution.

my input is an array, one by ten x=[x1 x2 x3... x10]

the only possible solutions include the constraint that each progressive element is greater than or equal to the one before it ie x3=>x2=>x1...

so I want to build a matrix with columns being each possible solution. Values for elements can be between 0 and .4 in increments of .01. I cant input zero, so I need to start at .00001.

This set up probably sounds pretty idiotic, but I've given up doing this a reasonable way - if someone could just help me construct the right set up of for loops or whatever, that'd be amazing.

Thanks,

Canopy
• May 1st 2009, 09:45 AM
CaptainBlack
Quote:

Originally Posted by canopy
Ok, so I'm not a programmer by any means, I'm a geologist - truth be told. I'm working on a melting model of the mantle and don't normally have to get too in depth with my MATLAB scripts.

I've been trying to use this function fmincon to find a minimum value for this function, but its not outputting believable answers. So I've decided to see if its possible to just brute force find a solution.

my input is an array, one by ten x=[x1 x2 x3... x10]

the only possible solutions include the constraint that each progressive element is greater than or equal to the one before it ie x3=>x2=>x1...

so I want to build a matrix with columns being each possible solution. Values for elements can be between 0 and .4 in increments of .01. I cant input zero, so I need to start at .00001.

This set up probably sounds pretty idiotic, but I've given up doing this a reasonable way - if someone could just help me construct the right set up of for loops or whatever, that'd be amazing.

Thanks,

Canopy

That is incomprehensible. Why don't you post the real question.

CB
• May 1st 2009, 10:00 AM
canopy
real question?
ok... I'm not sure what you mean by real question... but let me try to be more concise.

I need to write a matrix with an unknown number of columns, and 10 rows.

consider each column as a separate entity... here are the constraints on those columns:

-each element of a column has to be greater than or equal to the element above it.

-each element of a column has to be between 0 and .4, and possible increments are by .01

-in place of zero, .00001 must be used

the matrix should include all possible columns that satisfy these constraints.
• May 1st 2009, 12:29 PM
canopy
one last try
Let me rephrase that for clarity:

If my only possible values were 1, 2 and 3, and my columns were only 4 elements tall, I'd want to generate

0000000000000000000011111111122223
0000000000111111222311111222322233
0000111223111223223311223223322333
0123123233123233233313233233323333

instead though, I want it to have possible values between 0 and .4 by increments of .01, and be 10 elements tell.

finally, I cant have actual 0s, I need them to be .00001s instead
• May 1st 2009, 02:43 PM
aidan
Quote:

Originally Posted by canopy
Let me rephrase that for clarity:

If my only possible values were 1, 2 and 3, and my columns were only 4 elements tall, I'd want to generate

0000000000000000000011111111122223
0000000000111111222311111222322233
0000111223111223223311223223322333
0123123233123233233313233233323333

instead though, I want it to have possible values between 0 and .4 by increments of .01, and be 10 elements tell.

finally, I cant have actual 0s, I need them to be .00001s instead

If you can have zero, what are those thing I highlighted in red?

did you actually mean this:
Code:

``` 11111111122223 111111222311111222322233 111223111223223311223223322333 123123233123233233313233233323333```
Is this meant to be an array : ARRAY( ROWS 1 TO 4, COLUMNS 1)

What would a typical floating point valued array look like?
• May 1st 2009, 02:55 PM
canopy
q
those 0s are zeros, in this example. But in the actual algo I would need all zeros to be replaced by .00001
• May 1st 2009, 04:03 PM
aidan
From the info supplied, your contraints are not clear.
I do not know what you are trying to do.
Do you need sequential data or random data.

This is a fragment that will generate the entire sequence:

Code:

``` StartingValue = 0.00001 ColumnIncrement = 0.00001 RowIncrement = 0.01 dim Array( 1 to 10) for trial = 1 to 41 for c= 1 to 10 array(c) = startingvalue + i*columnIncrement + trial*RowIncrement next c '' run the trial with this data next trial```
The above creates the following:
Code:

```       1        2        3        4        5        6        7        8        9        10 1    0.00001  0.00002  0.00003  0.00004  0.00005  0.00006  0.00007  0.00008  0.00009  0.00010  2    0.01001  0.01002  0.01003  0.01004  0.01005  0.01006  0.01007  0.01008  0.01009  0.01010  3    0.02001  0.02002  0.02003  0.02004  0.02005  0.02006  0.02007  0.02008  0.02009  0.02010  4    0.03001  0.03002  0.03003  0.03004  0.03005  0.03006  0.03007  0.03008  0.03009  0.03010  5    0.04001  0.04002  0.04003  0.04004  0.04005  0.04006  0.04007  0.04008  0.04009  0.04010  6    0.05001  0.05002  0.05003  0.05004  0.05005  0.05006  0.05007  0.05008  0.05009  0.05010  7    0.06001  0.06002  0.06003  0.06004  0.06005  0.06006  0.06007  0.06008  0.06009  0.06010  8    0.07001  0.07002  0.07003  0.07004  0.07005  0.07006  0.07007  0.07008  0.07009  0.07010  9    0.08001  0.08002  0.08003  0.08004  0.08005  0.08006  0.08007  0.08008  0.08009  0.08010 10    0.09001  0.09002  0.09003  0.09004  0.09005  0.09006  0.09007  0.09008  0.09009  0.09010 11    0.10001  0.10002  0.10003  0.10004  0.10005  0.10006  0.10007  0.10008  0.10009  0.10010 12    0.11001  0.11002  0.11003  0.11004  0.11005  0.11006  0.11007  0.11008  0.11009  0.11010 13    0.12001  0.12002  0.12003  0.12004  0.12005  0.12006  0.12007  0.12008  0.12009  0.12010 14    0.13001  0.13002  0.13003  0.13004  0.13005  0.13006  0.13007  0.13008  0.13009  0.13010 15    0.14001  0.14002  0.14003  0.14004  0.14005  0.14006  0.14007  0.14008  0.14009  0.14010 16    0.15001  0.15002  0.15003  0.15004  0.15005  0.15006  0.15007  0.15008  0.15009  0.15010 17    0.16001  0.16002  0.16003  0.16004  0.16005  0.16006  0.16007  0.16008  0.16009  0.16010 18    0.17001  0.17002  0.17003  0.17004  0.17005  0.17006  0.17007  0.17008  0.17009  0.17010 19    0.18001  0.18002  0.18003  0.18004  0.18005  0.18006  0.18007  0.18008  0.18009  0.18010 20    0.19001  0.19002  0.19003  0.19004  0.19005  0.19006  0.19007  0.19008  0.19009  0.19010 21    0.20001  0.20002  0.20003  0.20004  0.20005  0.20006  0.20007  0.20008  0.20009  0.20010 22    0.21001  0.21002  0.21003  0.21004  0.21005  0.21006  0.21007  0.21008  0.21009  0.21010 23    0.22001  0.22002  0.22003  0.22004  0.22005  0.22006  0.22007  0.22008  0.22009  0.22010 24    0.23001  0.23002  0.23003  0.23004  0.23005  0.23006  0.23007  0.23008  0.23009  0.23010 25    0.24001  0.24002  0.24003  0.24004  0.24005  0.24006  0.24007  0.24008  0.24009  0.24010 26    0.25001  0.25002  0.25003  0.25004  0.25005  0.25006  0.25007  0.25008  0.25009  0.25010 27    0.26001  0.26002  0.26003  0.26004  0.26005  0.26006  0.26007  0.26008  0.26009  0.26010 28    0.27001  0.27002  0.27003  0.27004  0.27005  0.27006  0.27007  0.27008  0.27009  0.27010 29    0.28001  0.28002  0.28003  0.28004  0.28005  0.28006  0.28007  0.28008  0.28009  0.28010 30    0.29001  0.29002  0.29003  0.29004  0.29005  0.29006  0.29007  0.29008  0.29009  0.29010 31    0.30001  0.30002  0.30003  0.30004  0.30005  0.30006  0.30007  0.30008  0.30009  0.30010 32    0.31001  0.31002  0.31003  0.31004  0.31005  0.31006  0.31007  0.31008  0.31009  0.31010 33    0.32001  0.32002  0.32003  0.32004  0.32005  0.32006  0.32007  0.32008  0.32009  0.32010 34    0.33001  0.33002  0.33003  0.33004  0.33005  0.33006  0.33007  0.33008  0.33009  0.33010 35    0.34001  0.34002  0.34003  0.34004  0.34005  0.34006  0.34007  0.34008  0.34009  0.34010 36    0.35001  0.35002  0.35003  0.35004  0.35005  0.35006  0.35007  0.35008  0.35009  0.35010 37    0.36001  0.36002  0.36003  0.36004  0.36005  0.36006  0.36007  0.36008  0.36009  0.36010 38    0.37001  0.37002  0.37003  0.37004  0.37005  0.37006  0.37007  0.37008  0.37009  0.37010 39    0.38001  0.38002  0.38003  0.38004  0.38005  0.38006  0.38007  0.38008  0.38009  0.38010 40    0.39001  0.39002  0.39003  0.39004  0.39005  0.39006  0.39007  0.39008  0.39009  0.39010 41    0.40001  0.40002  0.40003  0.40004  0.40005  0.40006  0.40007  0.40008  0.40009  0.40010```
• May 1st 2009, 05:28 PM
canopy
?
I'm not totally clear what the example I presented has to do with your matrix there.
• May 2nd 2009, 07:01 AM
aidan
The transpose of my matrix above will give you 1 compete iteration as you requested:
Quote:

Originally Posted by canopy
ok...
I need to write a matrix with an unknown number of columns, and 10 rows.

It is actually 10 columns in 41 rows, so the transpose will apply.

Quote:

consider each column as a separate entity... here are the constraints on those columns:

-each element of a column has to be greater than or equal to the element above it.

-each element of a column has to be between 0 and .4, and possible increments are by .01

-in place of zero, .00001 must be used

the matrix should include all possible columns that satisfy these constraints.
The question I have:

Are you looking for a series with aritimetic increments, geometric increments or random increments?

Do you want ALL possible values for 0.0001 to 0.4 or do you need all values from 0.01 to 0.40 in random groups of ten (with the constraints mentioned)?

You could have 40,000 values (ranging from 0.00001 to 0.40) and taking them in groups of 10 to generate your input. That's a lot of brute force.

Since you are excluding zero, it appears as if the values you seek are logarithmic.

I am not sure what you are attempting to explain:
Code:

```0000000000000000000011111111122223 0000000000111111222311111222322233 0000111223111223223311223223322333 0123123233123233233313233233323333```
it looks as if you should have done this:
Code:

```0.000010.000010.000010.000010.00001.... 0.000010.000010.000010.000010.00001.... 0.000010.000010.000010.000011.00001.... 0.000011.000002.000003.000001.00000...```
The colors are there to indicate the width of the data in each column.

It is not clear at the moment if you are going to furnish your program 1 column of 10 values, or 40000 columns of data with 10 values per column at the start of the program run.

Could you provide a few examples of actual data that would be used in your program?