我生成了 4 个随机值。我如何使用 scilab 将它们写入第一行中仅由分号分隔的文本文件?

i have generated 4 random values. how do i write them into a text file in its first line separated only by a semicolon using scilab?

我已经使用 rand 函数生成了随机值,如下所示。

    h=0
    g=-120
    r1 = (h-g)*rand()+g;
    r2 = (h-g)*rand()+g;
    r3 = (h-g)*rand()+g;
    r4 = (h-g)*rand()+g;

如何将这些值复制到格式为“37;40;56;28”的文本文件中?

您可以在使用 csvwrite 时指定您自己的分隔符。

h=0
g=-120
M = (h-g)*rand(1,4)+g;
csvWrite(M, "my_file.csv", ";");