传递参数_ Shell脚本-八度脚本 [英] Pass Parameters _ Shell Script - Octave Script
本文介绍了传递参数_ Shell脚本-八度脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从Shell脚本向Octave脚本传递两个参数(数字向量)?
How can i pass two parameters (number vectors) from a Shell Script to a Octave Script ??
就是这个主意.
#!/bin/bash
.... do something that processing vector1 vector2
./draw.m Vector1 Vector2
在"draw.m"中
plot(Vector1, Vector2)
谢谢!
推荐答案
..而且,如果允许的话,我为Octave脚本添加了一个小的变体,因为前者位于Matlab中;)
..And, if you allow me, i add a small variation for a Octave Script since the former was in Matlab ;)
Arrays.sh
#!/bin/bash
# create random data
for i in {1..10}; do v1[$i]=$RANDOM; done
for i in {1..10}; do v2[$i]=$RANDOM; done
# save data to file
echo ${v1[@]} > file.txt
echo ${v2[@]} >> file.txt
# call OCTAVE script
octave draw.m
Draw.m
load ("-ascii", "file.txt")
plot(file(1,:), file(2,:)) %# if you want see the graphic
print('figure.ps', '-deps') %# save the result of 'plot' into a postscript file
exit
这篇关于传递参数_ Shell脚本-八度脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文