# i would like to create a randi function that will allow me to generate two arguments at one

1 visualizzazione (ultimi 30 giorni)
Marietou Ba il 2 Mar 2020
Risposto: M il 2 Mar 2020
i would like to create a randi function that will allow me to generate two arguments at one or make a function to shoot at the hazard n cell in a grid
exemple
Faire une fonction pour tirer au hazard n cellule dans une grille.
n= number of location
don't get the location or matrixx==nan
n=100
[nligne ncol]=randi([1 100],n)% its not corect
##### 0 CommentiMostra -1 commenti meno recentiNascondi -1 commenti meno recenti

Accedi per commentare.

### Risposta accettata

M il 2 Mar 2020
Suppose you have a n by n matrix:
n = 5;
T = magic(n);
You can access a random cell in this matrix by using:
c = randi(n,[1,2]);
Access the random location:
T(c(1),c(2))
##### 0 CommentiMostra -1 commenti meno recentiNascondi -1 commenti meno recenti

Accedi per commentare.

### Community Treasure Hunt

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

Start Hunting!