How to write a function which handles strings?

조회 수: 1 (최근 30일)
Lihini see
Lihini see 2020년 5월 6일
댓글: Lihini see 2020년 5월 6일
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
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
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 CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by