防止用户交互命令窗口的八度



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

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

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

要防止变量一起打印,只需在每个变量赋值的末尾添加分号:

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

最新更新