Cell array value based on poisiton

Hi,
I have created following code, It's basically based on input text search it in S array and returns poistion
S ={'a' 'b' 'c' 'd' 'e'; 'f' 'g' 'h' 'i' 'j'; 'k' 'l' 'm' 'n' 'o'; 'p' 'r' 's' 't' 'u'; 'v' 'w' 'x' 'y' 'z'}
Q=input('Enter the input text: ')
find(ismember(S, Q)==1)
Lets say input text is 'e' so output will be 21, Now i want to return 21th element from K array that is 't'
K={ 'g' 'm' 'r' 'i' 't'; 'a' 'b' 'c' 'd' 'e'; 'f' 'h' 'j' 'k' 'l'; 'n' 'o' 'p' 's' 'u'; 'v' 'w' 'x' 'y' 'z'}
How to retrive cell array value based on position. Pls guide me..
Thanks in Advance

1 件のコメント

Image Analyst
Image Analyst 2011 年 10 月 30 日
You mean 5 rather than 21 in this, don't you :"Lets say input text is 'e' so output will be 21, Now i want to return 21th element from K array that is 't'"

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

 採用された回答

the cyclist
the cyclist 2011 年 10 月 30 日

0 投票

foundIndex = find(ismember(S, Q)==1)
K{foundIndex}

1 件のコメント

Andrei Bobrov
Andrei Bobrov 2011 年 10 月 30 日
out = K(ismember(S,Q))

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

質問済み:

Nil
2011 年 10 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by