如何将文件路径变量传递给mex命令? [英] How to pass filepath variables to mex command?

查看:76
本文介绍了如何将文件路径变量传递给mex命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前正在尝试创建脚本化的mex文件生成的最小示例.

Currently trying to create a minimal example of scripted mex file generation.

我有一个正在运行的MATLAB .m脚本来生成mex文件.我想将所有参数作为变量传递,这样当给定文件名/路径列表时,我可以自动化一堆mex文件的构建.

I have a MATLAB .m script that I am running to generate mex files. I would like to pass in all the arguments as variables so that I can automate a bunch of mex file construction when given a list of filenames/paths.

#1 : unknown argument -outdir
input = ' -outdir C:/Users/ian/mexTesting/mexFiles'
mex('src/helloworld.cpp', input)

#2 : unknown filepath / can't find location (interprets entire string as path to mex file)
input = 'src/helloworld.cpp -outdir C:/Users/ian/mexTesting/mexFiles'
mex(input)

#3 : same issue as #2
mex input

#4 : Works, but no variables included, so no easy way to automate
mex src/helloworld.cpp -outdir /mexFiles

所有这些参数(#4除外)都得到未知的参数-outdir,或者将输入的char arr解释为mex文件的路径.

All of these (except #4) get either unknown argument -outdir or it interprets the input char arr as a path to a mex file.

有人知道如何将变量传递给mex命令吗?

Does anyone know how to pass variables into the mex command?

没有任何问题可以真正解答我的问题.任何帮助将不胜感激.

There are no questions that have actually answered this issue that I could find. Any help would be appreciated.

推荐答案

这应该可以解决问题:

input = 'src/helloworld.cpp';
output = '/mexFiles';

eval(['mex ' input ' -outdir ' output]);

这篇关于如何将文件路径变量传递给mex命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆