How can I get a user to input a number which is not already
Afficher commentaires plus anciens
Hi, I just want a user to input(input must be between 1-9) a new number, so store the input value in a vector and add every new input to that vector and every time the user input new number I just use a code to check is the input is already in the vector, but my code is not check every value in the vector.
o=[];
for i=1:4
num=input('Enter:');
while num<=0||num>=9
num=input('Enter exist number:');
end
for i=1:length(o)
if num==o(i)
while num==o(i)
num=input('Enter new:');
end
end
end
o=[o num];
end
This is my code, can anyone please help
Thanks,
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!