我正在尝试编写一个可以作为可执行文件运行的 Octave 脚本。
我使用的是八度音阶版本 3.6.0。我运行下面的脚本下载的形式在这里:
#!/usr/local/bin/octave -qf
# An example Octave script
len = input( "What size array do you wish to use for the evaluation: " );
clear a;
tic();
for i=1:len
a(i) = i;
endfor
time1 = toc();
a = [1];
tic();
for i=2:len
a = [a i];
endfor
time2 = toc();
a=zeros( len, 1 );
tic();
for i=1:len
a(i) = i;
endfor
time3 = toc();
printf( "The time taken for method 1 was %.4f seconds\n", time1 );
printf( "The time taken for method 2 was %.4f seconds\n", time2 );
printf( "The time taken for method 3 was %.4f seconds\n", time3 );
Run Code Online (Sandbox Code Playgroud)
但是,当我在命令行上运行脚本时,出现以下错误:
'usr/local/bin/octave: 无效选项 -- '
但是,当我在命令行中键入相同的命令时:
/usr/local/bin/octave -qf
我得到了八度命令提示符。我究竟做错了什么?