How to choose a random coordinate (location like i,j) in a matrix

1 Ansicht (letzte 30 Tage)
Ex: A[1 2 3; 4 5 6];
I want to select a random i,j of an element of this matrix
thank you in advance

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 28 Mai 2020
[m,n]=size(A);
i=randi([1 m]);
j=randi([1 n])

Weitere Antworten (0)

Kategorien

Mehr zu Random Number Generation finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by