Wednesday, March 17, 2010

Octave直接執行script

給未來的裕翔

如同bash可以寫shell script

octave其實也可以寫script
(m file應該不能直接這樣用, 上面要加一行)


如同shell script在最上面有個#!/bin/bash

octave在最上面的是#!/usr/bin/octave

之後一切都如同shell script

假設我的octave scripttest.oct
(副檔名不一定要oct, 甚至不需要副檔名, 隨我高興^^)


chmod u+x test.oct

./test.oct

不過如果script有出現要秀圖的部份

光剛那樣不夠

可以考慮另存圖檔, ex: output.png

test.oct裡面加上print -dpng output.png
(-d是device的意思, png是圖檔格式)


或是在shell下執行完test.oct之後直接進入octave

octave --persist test.oct

這樣秀圖的視窗就會保留住了





No comments:

Post a Comment