防止用户对命令 window 进行八度音程交互

Prevent user interaction on command window for octave

当我 运行 下面的八度编码命令 window 显示:

>> first
x =

    10
    20
    30
    40
    50
    60
    70
    80
    90
   100

y =

   14
   17
   18
   14
   15
   14
   13
   12
   11
    4

m =  10
x =

     1    10
     1    20
     1    30
     1    40
     1    50
     1    60
     1    70
     1    80
     1    90
     1   100

-- less -- (f)orward, (b)ack, (q)uit

我需要连续按 (f) 来完成程序并查看绘图:plot(x(:,2), x*theta, '-');

八度代码:

x = [10
    20
    30
    40
    50
    60
    70
    80
    90
    100]
y = [14
    17
    18
    14
    15
    14
    13
    12
    11
    4]

m = length(y)

x = [ones(m , 1) , x]

theta = zeros(2, 1);        

iterations = 10;
alpha = 0.000007;

for iter = 1:iterations
     theta = theta - ((1/m) * ((x * theta) - y)' * x)' * alpha;
     #theta
end

#plot(x, y, 'o');
#ylabel('Response Time')
#xlabel('Time since 0')
plot(x(:,2), x*theta, '-');

如何防止用户与命令 window 交互,以便程序 运行 完成并显示提示而不需要 用户互动 ?

为了防止您的变量完全打印,只需在每个变量赋值的末尾添加一个分号:

m = length(y)   %// **will** print to the console
m = length(y);  %// will *not* print to the console

要将变量打印到控制台,但要避免 Octave 在到达屏幕底部时暂停输出,请将 more off 添加到脚本的开头以关闭分页。

https://www.gnu.org/software/octave/doc/interpreter/Paging-Screen-Output.html

键入 more on 将其重新打开。