add uniform random number to matrix
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
NA
le 23 Juil 2019
Réponse apportée : Star Strider
le 23 Juil 2019
I want to add uniform number which change for each element of matrix.
But if I use this code, same number add to element of A
A=[1,2;2,4];
index=1;
uniform_test=unifrnd(1,3);
A(index,:)=uniform_test+A(index, :);
example of result
A=[2.5*1,1.2*2;2,4];
change uniform number of each element of A
0 commentaires
Réponse acceptée
Star Strider
le 23 Juil 2019
I am not certain what you are asking.
If you want to add different uniform random numbers with a minimum value of 1 and a maximum value of 3 to every element in ‘A’, you have to tell the unifrnd function to create a matrix the size of ‘A’.
Try this:
A=[1,2;2,4];
[r,c] = size(A);
uniform_test=unifrnd(1,3,r,c); % Random Matrix (Size Of ‘A’)
Anew = A + uniform_test
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!