在八度音阶的命令窗口上阻止用户交互

时间:2015-08-29 12:49:48

标签: octave

当我在八度音程下面运行时,命令窗口显示:

>> 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,' - ');

Octave代码:

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, '-');

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

1 个答案:

答案 0 :(得分:2)

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

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将其重新打开。

相关问题