indexing string in function
66 次查看(过去 30 天)
显示 更早的评论
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
6 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!