Please help me in generating new row vectors from a given row vector.
Ältere Kommentare anzeigen
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.
clc
clear all
UB = [ 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!
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!