How to write a function which handles strings?
5 次查看(过去 30 天)
显示 更早的评论
I need to write a simle function which uses strings as inputs.
As a example:
a= writes('hello')
function result = writes(words)
result=words
end
it produce a error " Undefined function 'writes' for input argument type 'char' "
I'm using live editor in matlab 2016.
help. Thanks
1 个评论
Rik
2020-5-6
There is no fundamental problem with your syntax, so the only possibility is that Matlab can't find your function.
采纳的回答
Sindar
2020-5-6
Live editor functionality changes a lot across versions, but my suggestion would be to put your function in a separate cell from the call, and make sure the function cell gets evaluated before the call line.
更多回答(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!