gpt4 book ai didi

matlab - 在多行上打印警告消息

转载 作者:太空宇宙 更新时间:2023-11-03 20:32:46 26 4
gpt4 key购买 nike

我正在尝试打印一条警告消息,该消息有点长并且包含 2 个变量调用。这是我的代码:

warning( 'MATLAB:questionable_argument', ...
'the arguments dt (%d) and h (%d) are sub-optimal. Consider increasing nt or decreasing nx.', ...
dt, h )

显然,在查看 MATLAB 代码时,文本行向右延伸。我怎样才能打破它,让它很好地包裹起来?我尝试了多种方法,但不断出现语法错误。

最佳答案

按照评论中的建议,只需在要换行的地方插入 \n 即可。您还可以为文本使用变量,以使其在代码中也易于阅读:

txt = sprintf(['the arguments dt (%d) and h (%d) are sub-optimal.\n'... 
'Consider increasing nt or decreasing nx.'],dt,h);
warning( 'MATLAB:questionable_argument',txt)

关于matlab - 在多行上打印警告消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44359182/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com