对于这是一个新问题,我深表歉意,但是我已经在此处阅读了文档,并且在使用子字符串之前不必输入任何命令.
I apologize if this is a newb question, but I have read the documentation here and it says nothing about having to input any command before using substring.
但是,当我尝试按以下方式调用它时:
However, when I try to call it as follows:
substring('hello world',2)
substring('hello world', 2)
这给了我错误
???对于类型为'char'的输入参数,未定义的函数或方法'substring'.
??? Undefined function or method 'substring' for input arguments of type 'char'.
调用此substring的正确方法是什么?
What is the correct way to invoke this substring?
推荐答案不要偏离OP的答案,实际上,OP的答案更直接地解决了您提出的问题,但是假设您要做的就是从中提取一定数量的字符一个字符串,MATLAB的索引就是您所需要的:
Not to detract from the OP's answer, which actually more directly adresses the question you ask, but assuming all you want to do is extract a certain number of characters from a string, MATLAB's indexing is all you need:
myString = 'Hello, world!'; mySubstring = myString(3:end) mySubstring = llo, world!更多推荐
如何在Matlab中使用子字符串?
发布评论