bash - 将字符串参数从 bash 脚本传递到 matlab 文件的最接近方法是什么?

标签 bash matlab parameters

我有 matlab 文件 matlab_param.m

function matlab_param(param1, param2)

disp(sprintf('param1 : %s', param1));
disp(sprintf('param2 : %s', param2));

我想要 bash 脚本 bash_param.sh 看起来像

#!/bin/bash
echo $1
echo $2
./matlab_param.m $1 $2

我想运行这个 bashscirpt

./bash_param.sh hello world

它会打印

hello
world
param1 : hello
param2 : world

我在谷歌上搜索了几个小时,但找不到任何确切的解决方案。到目前为止我得到的最接近的是

matlab -nodesktop -nosplash -nodisplay -r "try, run ('./test_param.m'); end; quit"

我需要对所有参数进行硬编码。

最佳答案

你试过吗:

#!/bin/bash
echo $1
echo $2
matlab -nodesktop -nosplash -nodisplay -r "try, test_param('$1','$2'); end; quit"

关于bash - 将字符串参数从 bash 脚本传递到 matlab 文件的最接近方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10029872/

相关文章:

bash - 在 Bash 中转义双引号和单引号

matlab - PCA 在 3D 图像上获得 3 个主轴

javascript - 动态函数和动态参数/自变量

ruby - Ruby 如何允许方法参数默认值从早期参数派生?

java - 为什么 View 的操作(在本例中为按钮)必须采用 View 作为参数?

linux - bash 中信号之间的最短时间

bash - 带有 bash 大括号扩展的 cp 复制命令

python - "Converting"Numpy 数组到 Matlab,反之亦然

c++ - 如何在 Windows 7 上将 matlab 与 Qt 集成

linux - 加载不受信任的配置变量