result.txt" />
开发者

Using octave headless

Is there a possibility to us开发者_如何学Pythone Octave headless.

Something like this octave < "5+4" >result.txt


Using

octave --silent --eval 5+4 > result.txt

you'll get

ans =  9

in result.txt. See octave --help for details about command-line arguments.

Yet, there is this infamous ans = that might be remove using sed, e.g.

octave --silent --eval 'x=5+4; y=x+1; disp(y)' | sed -e 's/ans = //' >> result.txt

which add the appropriate result (10) in result.txt.

It should not be too hard to wrap this into a bash script.


Well there is always the option of writing a script file which saves the results of your computations to a text file. Then when invoking octave you just do:

octave scriptname.m

for example: testfile.m

Return = 5+4;
save('results.txt','Return')

Then from the command line:

octave -q testfile.m

and you should get the results you want in a file called results.txt and it will immediately terminate after. Is there some reason why this option wont work?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜