How to write a function which handles strings?

1 Ansicht (letzte 30 Tage)
Lihini see
Lihini see am 6 Mai 2020
Kommentiert: Lihini see am 6 Mai 2020
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 Kommentar
Rik
Rik am 6 Mai 2020
There is no fundamental problem with your syntax, so the only possibility is that Matlab can't find your function.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Sindar
Sindar am 6 Mai 2020
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.

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by