MATLAB 连接组合可变长度字符串和向量
许多近似解决方案都在网上,但没有确切的...
我正在逐个向量构建数据矩阵:
OutputMatrix(NextSubject,:)=[OutputVector]
我需要用该循环中正在处理的数据的名称来引导每一行。名称的形式为:
12345.dat
因此,如果 OutputVector=[1 2 3 4]
输出应如下所示:
12345.dat 1 2 3 4
我已经尝试了数十种解决方案,但有几个示例:
{char(Filename(i).name) OutputVector}
{strcat((Filename(i).name) OutputVector)}
[Filname(i).name OutputVector]
有帮助吗?请 :)
Many near-solutions are online, but nothing exact...
I am building a data matrix vector-by-vector:
OutputMatrix(NextSubject,:)=[OutputVector]
I need to lead each row with the name of the data being processed in that loop. The name has the form:
12345.dat
So if OutputVector=[1 2 3 4]
the output should look like:
12345.dat 1 2 3 4
I have tried dozens of solutions, but a few examples:
{char(Filename(i).name) OutputVector}
{strcat((Filename(i).name) OutputVector)}
[Filname(i).name OutputVector]
Any help? Please :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能在矩阵中存储字符串和向量。但是,您可以在单元格中执行此操作。
因此,您可能会考虑这样做:
大括号表示您将对象存储为单元格。
通常,最好将字符串和数字分开存储。类似于:
然后,如果您从输出矩阵访问或选择行,请对元胞数组使用相同的索引:
You can't store a string and a vector in a matrix. However, you can do that in a cell.
So you might consider doing:
The curly braces denote that you are storing the object as a cell.
Often though it is better to store strings and number separately. Something like:
Then if you access or select rows from output matrix, use the same index for the cell array: