防止用户在八度的命令窗口上进行交互 [英] Prevent user interaction on command window for octave

查看:51
本文介绍了防止用户在八度的命令窗口上进行交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

<代码>>>第一的x =102030405060708090100y =1417181415141312114米 = 10x =1 101 201 301 401 501 601 701 801 901 100-- 少 -- (f)forward, (b)ack, (q)uit

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

八度代码:

x = [102030405060708090100]y = [1417181415141312114]m = 长度(y)x = [ones(m , 1) , x]θ = 零(2, 1);迭代 = 10;阿尔法 = 0.000007;对于 iter = 1:iterationstheta = theta - ((1/m) * ((x * theta) - y)' * x)' * alpha;#theta结尾#plot(x, y, 'o');#ylabel('响应时间')#xlabel('从 0 开始的时间')plot(x(:,2), x*theta, '-');

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

解决方案

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

m = length(y) %//**将**打印到控制台m = 长度(y);%//不会*打印到控制台

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

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

输入 more on 将其重新打开.

When I run below octave code the command window displays :

>> 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

I'm required to continually press (f) to complete program and view plot : plot(x(:,2), x*theta, '-');

Octave code :

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

How to prevent user interaction with command window so that program runs to completion and displays prompt and not requiring user interaction ?

解决方案

To prevent your variables from printing altogether, simply add a semicolon to the end of each variable assignment:

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

To print your variables to the console, but avoid Octave pausing the output when it gets to the bottom of the screen, add more off to the beginning of your script to turn off paging.

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

Type more on to switch it back on.

这篇关于防止用户在八度的命令窗口上进行交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆