【问题标题】:Adding newline character in string (Matlab)在字符串中添加换行符(Matlab)
【发布时间】:2023-03-30 22:09:01
【问题描述】:

如何在Matlab中为等效Java代码的字符串添加换行符?

String line;
line += "\n";

【问题讨论】:

  • 试试line = strcat (line, char(10))

标签: string matlab char newline


【解决方案1】:

来自以下链接

str = sprintf('test \n test')
or 
str = ['test ' char(10) ' 'test']
  1. strcat
  2. Inserting_Newlines_into_Disp_Warn_and_Error
  3. how to add a newline symbol into a string?

【讨论】:

  • 第二个选项应该是 str = ['test', char(10) ,'test']
【解决方案2】:

“换行符”取决于您使用的操作系统...最好的解决方案是

line = sprintf('%s\n', line);

这将强制 Matlab 使用操作系统的“正确”回车。

【讨论】:

    猜你喜欢
    • 2013-05-12
    • 2014-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-05
    • 2010-09-18
    • 2021-06-14
    相关资源
    最近更新 更多