how to assign characters?

2 ビュー (過去 30 日間)
Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran 2013 年 2 月 14 日
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..

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 14 日
data.a='u';
data.b='w'
x=input('input','s');
s=data.(x)
  7 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 14 日
編集済み: Azzi Abdelmalek 2013 年 2 月 14 日
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 2013 年 2 月 15 日
It works well for a single word... how about for a sentence

サインインしてコメントする。

その他の回答 (1 件)

Jan
Jan 2013 年 2 月 14 日
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)

カテゴリ

Help Center および File ExchangeDownloads についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by