【问题标题】:Run matlab command line and automate running unix server bjobs运行 matlab 命令行并自动运行 unix 服务器 bjob​​s
【发布时间】:2012-12-04 18:29:36
【问题描述】:

我正在以这种方式运行一段名为 fit.m 的 matlab 代码,

clear all;
load('/pathtomatfile/alldata.mat')
count = rxw1;
count = double(count);
x_cov = ltgbd;

alldata.mat 有几个感兴趣的数据,即,

rxw1
rbg2
rfd1
wop3, 
ltgbd,
etc.

我可以从命令行为给定的感兴趣数据运行此类脚本(在我的示例中为 count=rxw1),

matlab -nodisplay -nojvm -nosplash -r ${pathtoscript}fit -logfile lfile.txt

但是,我需要自动化运行,以便我可以告诉 matlab 使 count = mat 文件中的任何其他数据集。即,我想为不同的数据集并行编写脚本,但我需要类似的东西:

matlab -nodisplay -nojvm -nosplash -r ${pathtoscript}fit -logfile lfile.txt DATAOFINTERESTHERE (i.e., rxw1 count will equal rxw1, etc.)

可以按照我的建议去做吗?我如何通过在调用脚本时将数据集的名称作为输入参数来自动运行脚本以针对我选择的任何数据集运行?

一旦有了这些,我计划通过 LSF 提交作业来实际并行运行它们,但将感兴趣的数据的名称作为输入,记住这样的事情:

bsub -q week -R'rusage[mem=8000]' \
"matlab -nodisplay -nojvm -nosplash -r ${pathtoscript}fit -logfile lfile.txt DATAOFINTEREST"

对不起,如果 Q 太基础但我不熟悉运行 matlab 命令行。

【问题讨论】:

    标签: bash matlab lsf


    【解决方案1】:

    您可以将fit 设为函数,而不是脚本。 fit 函数 可以有一个指向正确数据文件的输入变量。 然后就可以运行了

    matlab -nodisplay -nojvm -nosplash -r "cd ${pathtoscript}; fit('${dataofinterest}');exit;"
    

    编辑:添加了这个详细的fit fun。

    您的 fit 函数应该类似于

    function fit( variableName )
    %
    % run fit for a specific variable from the mat file
    % variableName is a string, e.g. variableName = 'rgb1';
    %
    
    ld = load('/pathtomatfile/alldata.mat');
    count = ld.(variableName); % access variables in mat file as struct fields
    count = double( count );
    % and I believe you can take it from here...
    

    编辑: 类似的解决方案将 mat 文件加载到结构中以处理加载的变量 可以在here 找到更多详细信息。

    【讨论】:

    • 非常感谢。但它并没有解决我的问题,因为我没有很多 mat 文件。 mat 文件只是一个文件,里面有我感兴趣的所有数据(变量),这是我面临的主要问题。我可以尝试拆分此类文件,但正在寻找更方便的东西。
    • @Dnaiel 我编辑了我的答案,我相信它现在可以解决你的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-28
    • 2013-01-15
    • 2010-11-03
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多