From: carlos on 18 May 2010 18:45 Hi everyone!! I'm doing a guide interface in which there are one button press and one edit text. When you press the button you got a number with 5 unique figures. I'd like to have at least 10 figures, how can I do it?? Many thanks before hand, Carlos.
From: Walter Roberson on 18 May 2010 18:50 carlos wrote: > I'm doing a guide interface in which there are one button press and one > edit text. > When you press the button you got a number with 5 unique figures. I'd > like to have at least 10 figures, how can I do it?? set(Edit_box_handle, 'String', sprintf('%.10g', NumericValue)); Or instead of %.10g you might want %.10f
From: ImageAnalyst on 18 May 2010 21:31 Carlos: Is this what you're thinking of? % Find out how many digits to create, anywhere from 5 to 10. numberOfDigits =int32(5*rand(1)+5) % Get 10 unique and randomly arranged digits in the range 0-9 randomUniqueNumbers = randperm(10) - 1 % Take just numberOfDigits of them. randomUniqueNumbers = randomUniqueNumbers(1:numberOfDigits) % Turn it into a string. strNumber = num2str(randomUniqueNumbers) % The string has spaces, so get rid of them. strNumber(strNumber==' ')=[]
|
Pages: 1 Prev: solving nonlinear simultaneous equations Next: How we can make surface extrapolation |