X random integers between 1 and 25

hello, im trying to create code to give me X random integers (defined by dialog box) between 1 and 25. i have a working dialog box to give me the X but i cant get the randi function to give me what i need. any help is appreciated. thanks

4 Commenti

randi command has the power to help you
did you wrote it in randi([1 25],[1 1]) ??
that seems to give me 1 random number between 1 and 25. I would like X random numbers without repeating any number. how would that look?
david smart
david smart il 17 Ott 2017
Modificato: david smart il 17 Ott 2017
sorry, it seems the problem isnt with my random number generator, its with my dialog box.
prompt = {'Enter how many noise pixils (0 to 25) to add to the picture:'};
dlg_title = 'Noise Addition';
num_lines = 1;
defaultans = {'0'};
usernoise= inputdlg(prompt,dlg_title,num_lines,defaultans)
%create noise matrix
r =randperm(25,usernoise)
how can i get that to use the user input?
usernoise = str2double(usernoise{1})
Usernoise is returned as a cell array containing strings.

Accedi per commentare.

Categorie

Scopri di più su Random Number Generation in Centro assistenza e File Exchange

Richiesto:

il 17 Ott 2017

Commentato:

il 17 Ott 2017

Community Treasure Hunt

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

Start Hunting!

Translated by