在八度构建一个带有空字符串的矩阵,然后在每行中用不均匀的字符填充
我在 MATLAB 中有一段工作代码
empty_string = "";
bag = repmat(empty_string, 4, 1);
bag(2) = "second row";
bag(3) = "third";
,但是,我想将其转换为八度音程,因为 MATLAB 是许可版本,每个人都无法访问它。
empty_string = blanks(1);
bag = repmat(empty_string, 4, 1);
bag(2) = "second row";
bag(3) = "third";
这给出了 error: =: nonconformant argument (op1 is 1x1, op2 is 1x10)
我希望矩阵“bag”的每一行都填充奇数个字符,请建议如何做到这一点八度。谢谢。
I have a working piece of code in MATLAB
empty_string = "";
bag = repmat(empty_string, 4, 1);
bag(2) = "second row";
bag(3) = "third";
However, I want to convert this to octave as MATLAB is a licensed version and everyone can't get access to it.
empty_string = blanks(1);
bag = repmat(empty_string, 4, 1);
bag(2) = "second row";
bag(3) = "third";
This gives error: =: nonconformant arguments (op1 is 1x1, op2 is 1x10)
I want each row of matrix 'bag' to be filled with uneven number of characters, please suggest how this can be done in octave. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于matlab strings> strings 尚未在octave中实现,您将需要使用char阵列的单元格数组。幸运的是,这很简单。只需更改代码示例中的前两行即可创建一个适当大小的单元格数:
结果是:
一个烦恼是为了在单元格数组中引用char数组,您需要使用卷曲括号而不是括号:
Since MATLAB strings have not been implemented in Octave, you will need to use a cell array of char arrays. Fortunately, this is pretty simple. Just change the first two lines in your code sample to create a cell array of the proper size:
The result is:
The one annoyance is that in order to reference your char arrays in the cell array, you need to use curly braces instead of parentheses: