如何在Matlab中使用子字符串?

编程入门 行业动态 更新时间:2024-10-25 04:23:20
本文介绍了如何在Matlab中使用子字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

对于这是一个新问题,我深表歉意,但是我已经在此处阅读了文档,并且在使用子字符串之前不必输入任何命令.

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中使用子字符串?

本文发布于:2023-10-27 02:54:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1532097.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   如何在   Matlab

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!