console - 将文本输出到 Octave 控制台

标签 console line octave output

假设我有一个变量 A=5我想输出它,但在它的前后添加了一些文本。像这样:"There are 5 horses." (请注意 5 应该是可变变量 A )

如果我写:disp("There are "),disp(A),disp(" horses.")我得到:

There are 
5
 horses.

但我希望所有内容都在一行中。

我该怎么做?

最佳答案

您可以使用:

A = 5
printf("There are %d horses\n", A)

输出:
There are 5 horses

甚至
disp(["There are ", num2str(A), " horses"])

甚至
disp(strcat("There are ", num2str(A), " horses"))

但是你必须添加一些东西,因为 Octave /matlab 不允许字符串末尾的空格,所以输出是:
ans = There are5 horses

关于console - 将文本输出到 Octave 控制台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15266535/

相关文章:

c++ - 可选择写入 C++ 控制台的 Windows 应用程序?

mysql - 在 MYSQL CONSOLE 中触发

python - python中不规则点之间的坐标列表

java - 用Java画对角线

macos - Octave 在需要绘图时卡住

statistics - Octave mann-whitney/u_test p 值混淆

python - 是否可以在 IPython 控制台中显示 Pandas 样式?

image - firefox 在 png 的内容框边缘以特定宽度呈现灰色细线 - 为什么?

gnuplot - 将图例文本的 Horizo​​ntalAlignment 设置为左​​ Octave

ios - 发布时无法将 nslog 打印到组织者的控制台