Matlab字符到字符串的转换问题。使用什么功能?
x = 1234 56789 7654
x(1) 是 1,x(2) 是 2 等等...中间有 5 个空格.. 尺寸(x) = 1 23 1行23列 我尝试过使用 num2str、strcat 但我无法合并数字。 y = num2str(x), y = strcat(x)
我希望它是.. x(1) = 1234, x(2) = 56789, x(3) = 7654
我应该使用什么函数来完成上述操作?
x = 1234 56789 7654
x(1) is 1, x(2) is 2 and so on... there are 5 spaces in between..
size(x) = 1 23
One row with 23 columns
I've tried using num2str, strcat but I cannot club the numbers.
y = num2str(x), y = strcat(x)
I want it to be.. x(1) = 1234, x(2) = 56789, x(3) = 7654
What function should I use to accomplish the above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
简单的解决方案是使用 sscanf:
Simple solution is to use
sscanf
:有多种方法可以执行您想要的操作。其中之一是 strtok。
There are several ways of performing what you want. One of them is strtok.
STR2NUM 非常适合此任务:
STR2NUM works well for this task:
只是为了添加另一个答案......
Just to add another answer to the mix...
下面创建一个字符串元胞数组,然后使用 sscanf 应用程序。
The following creates a cell array of strings then follows it up with an application of sscanf.