MATLAB: Indexing string in function

functionindexstring

I have a function that i want to return the first and last word from a string. so for example firstAndLast('matlab') should give me (m,b), however i am only able to get the first letter from this function?
function [first,last] = firstAndLast(instring)
first=instring(1);
last=instring(length(instring));
end

Best Answer

Words
>> C = regexp('the quick brown fox','\S+','match');
>> C([1,end])
ans =
'the' 'fox'
Letters
>> fun = @(s)s([1,end]);
>> fun('matlab')
ans =
mb