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..

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 14 de Feb. de 2013

0 votos

data.a='u';
data.b='w'
x=input('input','s');
s=data.(x)

7 comentarios

Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran el 14 de Feb. de 2013
wow.. it works fine..thanks Abdel..
Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran el 14 de Feb. de 2013
your answer suits the best for a single letter. now my input is siva. my answer should be tfjs. how to get it. next doubt is.. i can give any input of my own choice. it can be of any length of characters. to be in short, it should be as like encryption.
Azzi Abdelmalek
Azzi Abdelmalek el 14 de Feb. de 2013
There is no difference
data.tfjs='siva';
x=input('input','s');
s=data.(x)
Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran el 14 de Feb. de 2013
you fixed the word siva. i am not supposed to fix it... user may give any input
Azzi Abdelmalek
Azzi Abdelmalek el 14 de Feb. de 2013
Editada: Azzi Abdelmalek el 14 de Feb. de 2013
What do you mean? you said siva corresponds to tfjs. You have then to put it in your code or no? Or explain
Azzi Abdelmalek
Azzi Abdelmalek el 14 de Feb. de 2013
Editada: Azzi Abdelmalek el 14 de Feb. de 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 el 15 de Feb. de 2013
It works well for a single word... how about for a sentence

Iniciar sesión para comentar.

Más respuestas (1)

Jan
Jan el 14 de Feb. de 2013

0 votos

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)

Categorías

Productos

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by