【问题标题】:How to Run Unix command in Matlab in Windows?如何在 Windows 的 Matlab 中运行 Unix 命令?
【发布时间】:2015-07-28 07:11:24
【问题描述】:

在此 MATLAB 代码中,为 UNIX 平台标识了命令。但是,我使用的是Win7。如何在 Windows 的 Matlab 中运行该命令?

command = ['Code/ExternalCode/kmeans/./kmeans_clustering.sh -i ' 'TemporaryResults/Features_ForKmeans' ' -p 2 -d -n ' num2str(k)];
system(command);
labels_kmeans = dlmread('TemporaryResults/Features_ForKmeans.membership');
labels_kmeans(:,1) = [];

【问题讨论】:

    标签: linux windows matlab unix command


    【解决方案1】:

    您至少有两个选项,都假设在脚本中执行的命令可在 Windows 上运行,即执行的程序存在并为 Windows 编译。

    1.) 尝试在 Windows 上运行未修改的 shell/bash 脚本:

    您需要安装一个可以在 Windows 上运行您的脚本的解释器,看看这个 SO 问题:Is there a way to run Bash scripts on Windows?

    2.) 将脚本重写为Windows batch format

    这取决于您正在运行的实际脚本,包括查找与 .sh 脚本中包含的命令相对应的批处理等效命令。

    【讨论】:

    • Cygwin 是运行 Unix 命令的好工具。但是,我不知道如何从 Matlab 管理该工具。
    • @michaelscolfield 在你的 cywgin 安装中应该有一个 bash.exe,它将执行脚本,所以像 system('c:\path\to\cygwin\bin\bash.exe kmeans_clustering.sh -i TemporaryResults/Features_ForKmeans ... ') 这样的东西应该可以工作
    猜你喜欢
    • 2014-12-28
    • 1970-01-01
    • 2020-06-08
    • 1970-01-01
    • 1970-01-01
    • 2012-07-03
    • 1970-01-01
    • 2014-08-23
    • 1970-01-01
    相关资源
    最近更新 更多