Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Matrix variable with parametric elements
Replies: 10   Last Post: Dec 26, 2012 5:38 PM

 Messages: [ Previous | Next ]
 Roger Stafford Posts: 5,929 Registered: 12/7/04
Re: Matrix variable with parametric elements
Posted: Dec 26, 2012 9:06 AM

"Michael Doukas" wrote in message <kbet38\$613\$1@newscl01ah.mathworks.com>...
> I do not have the prerequisite that the col(i+1) contains col(i)+1 elements.
> The ranges in my first post are just an example.
> My problem specific ranges are:
> col1: 0:2
> col2: 3:4
> col3: 5:7
> col4: 8:11
> col5: 12: 22
> col6: 23:24
> col7: 25:26
> col8: 27:39
> col9: 40:52
>
> For each column one random integer must be selected.
> Therefore, two possible rows of the resulting array (B) may be:
> Brow1=[1,4,7,9,15,23,25,32,50]
> Brow2=[0,3,5,8,14,23,26,29,42]

- - - - - - - - - - -
Let c be a row vector which gives the initial value of each column integer range together with a final element which is 1 greater than the end of the last range. (In your example it would be as below.)

c = [0,3,5,8,12,23,25,27,40,53];
n = length(c)-1;
m = 40;
M = floor(repmat(diff(c),m,1).*rand(m,n))+repmat(c(1:n),m,1);

Roger Stafford

Date Subject Author
12/26/12 Michael Doukas
12/26/12 Nasser Abbasi
12/26/12 Nasser Abbasi
12/26/12 Michael Doukas
12/26/12 Nasser Abbasi
12/26/12 Michael Doukas
12/26/12 Roger Stafford
12/26/12 Michael Doukas
12/26/12 Nasser Abbasi
12/26/12 Roger Stafford
12/26/12 Nasser Abbasi