필터 지우기
필터 지우기

How to generate a list of random ID which can later be used instead of participant name?

조회 수: 8 (최근 30일)
Hello every one,
I want to programm a code in which I can generate a list of random ID to use as test person ID later during my experiments.
- Each ID has to be consisted of 2 letters as well as 2 digits (e.g., 2g9e)
I would be so thankful if somebody could advise me how to do so.
Best regards,
Parishad

채택된 답변

Paul Hoffrichter
Paul Hoffrichter 2021년 3월 4일
Due to the cyclist remark about homework, I am just starting the script. It leaves out certain patterns like 'a9a9' since it is just using combinations. How you rearrange the unique patterns is up to you.
a_26_2 = nchoosek('a':'z',2);
n_10_2 = nchoosek('0':'9',2);
a_26_2f = [a_26_2; fliplr(a_26_2)]; % gives 650 2 letter unique alpha strings
n_10_2f = [n_10_2; fliplr(n_10_2)]; % gives 90 2 letter unique numeric strings
By merging all possibilities, you can get 650*90 (almost 60,000) unique 4 char id's.
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 3월 4일
We are not told that letters are restricted to lowercase.
We are also not told to avoid easily confused possibilities such as l0lO
Paul Hoffrichter
Paul Hoffrichter 2021년 3월 5일
True. But if homework as @the cyclist was trying to determine, getting a start is better than nothing.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

David Hill
David Hill 2021년 3월 4일
Yes, a strictly numerical format would be much easier.
a=[randperm(10,2)+47;randperm(26,2)+96];
a=char(a(:)');
  댓글 수: 3
Walter Roberson
Walter Roberson 2021년 3월 4일
We are not promised that the order of digits and letters is fixed, just that there are two of each.
Parishad Bromandnia
Parishad Bromandnia 2021년 3월 5일
@Paul Hoffrichter Thank you so much for your effort :)
Thats what I need and enough for my purpose.
Best,
Parishad

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by