【问题标题】:How to concatenate strings in gnuplot?如何在gnuplot中连接字符串?
【发布时间】:2016-07-08 09:25:11
【问题描述】:

假设我们有两个字符串:

String1 = 'This is '
String2 = 'a mouse.'

如何在 gnuplot 中连接这 2 个字符串以形成字符串 'This is a mouse.'

【问题讨论】:

    标签: gnuplot


    【解决方案1】:

    给定两个字符串

    String1 = 'This is ' 
    String2 = 'a mouse.'
    

    要连接它们,您可以使用任一

    String3 = String1.String2
    

    或更灵活的:

    String3 = sprintf("%s%s", String1, String2)
    

    输入 help stringhelp sprintf 了解有关这两种方法的更多信息。

    【讨论】:

    • 我有一种情况,这不起作用:使用columnheader(1)时,它在plot ... title columnheader(1)中有效(plot ... title "Avail."也是如此),但尝试连接columnheader(1)并不起作用"Avail."。类似f_sprintf: attempt to print numeric value with string format...的消息(我的数据文件的第一列包含一个固定字符串,例如"/var"(带有那些双引号))
    • 找到了解决方案:使用 columnhead(1) 而不是 `columnheader(1)` 解决了这个问题,即使我不明白。
    猜你喜欢
    • 1970-01-01
    • 2012-09-24
    • 2011-09-11
    • 2014-07-24
    • 2016-11-07
    • 2010-12-16
    • 2016-06-26
    • 1970-01-01
    相关资源
    最近更新 更多