gpt4 book ai didi

shell - 传递参数_Shell脚本-Octave脚本

转载 作者:太空宇宙 更新时间:2023-11-03 20:26:46 24 4
gpt4 key购买 nike

我如何将两个参数(数字向量)从 Shell 脚本传递到 Octave 脚本??

就是这个意思..

在“prove.sh”中

 #!/bin/bash

.... do something that processing vector1 vector2

./draw.m Vector1 Vector2

在“draw.m”中


 plot(Vector1, Vector2)

谢谢!!

最佳答案

..而且,如果你允许的话,我会为 Octave 脚本添加一个小的变化,因为前者是在 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 - 传递参数_Shell脚本-Octave脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4724756/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com