How do you replace letters so that they are not the same as the original?

1 Ansicht (letzte 30 Tage)
I have a code that uses the word 'elephant' and replaces it with random letters. I would like the first and second e's and a to be replaced with letters other than 'e' and 'a'. Is there any possible way to do this?
  2 Kommentare
Image Analyst
Image Analyst am 26 Sep. 2013
Bearbeitet: Image Analyst am 26 Sep. 2013
Seems like a strange thing to do...is this a homework assignment? And do you want all vowels not to be replaced with themselves ? Or not to be replaced with other vowels ? Or just e can't go to e or a and a also can't go to e or a? Please clarify how specific or general the requirements are.
Jaime
Jaime am 26 Sep. 2013
It is just code that I am running to gain some experience on Matlab before I start a course next year. I am trying to get the word 'elephant' to appear in a figure window in matlab with the vowels replaced with any other letter just not the original vowel. example e cannot be replaced with e. If that makes more sense

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 26 Sep. 2013
Bearbeitet: Azzi Abdelmalek am 26 Sep. 2013
s='elephant'
alf=setdiff('a':'z','ae')
s(ismember(s,'ae'))=alf(randperm(numel(alf),3))
% In the previous the 3 letters are different. If you want allow repetition
s='elephant'
alf=setdiff('a':'z','ae')
s(ismember(s,'ae'))=alf(randi(numel(alf),1,3))
  1 Kommentar
Azzi Abdelmalek
Azzi Abdelmalek am 26 Sep. 2013
You have to precise:
replace all a and e by any other letters or any other vowels? and please post the code you are using

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by