how to assign characters?
7 次查看(过去 30 天)
显示 更早的评论
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..
0 个评论
采纳的回答
Azzi Abdelmalek
2013-2-14
data.a='u';
data.b='w'
x=input('input','s');
s=data.(x)
7 个评论
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
更多回答(1 个)
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)
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!