For example, I have a row vector A
A = [ 4 2 6 1 5 ];
Whose elements are bounded by an upper bound
UB = [ 5 4 6 3 5 ]
Now from this row vector 'A', N (length (A)), new vectors are to be generated. In each vector, an element of the vector A changes the value randomly within the upper bound and rest of the elements remains same.
For example, for above vector A, in first new vector A1, first element changes randomly within bound of [0-5] and rest of the elements remains same. Similarly, other vectors are generated.
A1 = [ 3 2 6 1 5 ];
Rests of the new vectors are
A2 = [ 4 1 6 1 5 ];A3 = [ 4 2 3 1 5 ];A4 = [ 4 2 6 3 5 ];A5 = [ 4 2 6 1 2 ];
I am using this code but couldn’t get the desired answer.
clcclear allUB = [ 5 4 6 3 5 ]A = [ 4 2 6 1 5 ];for i = 1:length(A) A(i) = randi(UB(i));end
Please help. Thanks in anticipation!
Best Answer