Effacer les filtres
Effacer les filtres

how to assign characters?

7 vues (au cours des 30 derniers jours)
Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran le 14 Fév 2013
if my input is a, then i should get always as u.... input is b means i should always get as w..... what techniques should be followed to achieve this.. should i use string concept..

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 14 Fév 2013
data.a='u';
data.b='w'
x=input('input','s');
s=data.(x)
  7 commentaires
Azzi Abdelmalek
Azzi Abdelmalek le 14 Fév 2013
Modifié(e) : Azzi Abdelmalek le 14 Fév 2013
Maybe you want this
data.a='u';
data.b='w'
x=input('input','s');
n=numel(x);
for k=1:n
s(k)=data.(x(k))
end
Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran le 15 Fév 2013
It works well for a single word... how about for a sentence

Connectez-vous pour commenter.

Plus de réponses (1)

Jan
Jan le 14 Fév 2013
You can create a lookup table:
pool = repmat(char(0), 1, 255);
pool('a') = 'u';
pool('b') = 'w';
...
% Or together:
pool('ab') = 'uw'; % A strange indexing, but it works
And then:
c = 'a';
pool(c)

Catégories

En savoir plus sur MATLAB Compiler dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by