MATLAB: Trying to make a function who says the position for a letter in the alphabet

decryptionstringtext;textstring

I can't figure out how to get this fuction to work. I need to use a letter as input, for example a, and the funkttion to return its position (1).
function h = postiton(a)
Alfabetet=['a';'b';'c';'d';'e';'f';'g';'h';'i';'j';'k';'l';'m';'n';'o';'p';'q';'r';'s';'t';'u';'v';'w';'x';'y';'z';];
h=find(Alfabetet==a))
end
How do i get this to work?
I want to write position(k) and get ans=11

Best Answer

Try this:
function test
aPosition = postiton('a')
function h = postiton(theLetter)
Alfabetet=['a';'b';'c';'d';'e';'f';'g';'h';'i';'j';'k';'l';'m';'n';'o';'p';'q';'r';'s';'t';'u';'v';'w';'x';'y';'z';];
h = find(ismember(Alfabetet, theLetter));