Workaround for fake file in memory?

5 ビュー (過去 30 日間)
Ray Lee
Ray Lee 2015 年 9 月 7 日
回答済み: Walter Roberson 2015 年 9 月 7 日
I have a mex function which reads data from a file and process it
result = mex_process_data(string_path_to_file);
The data is downloaded from website directly using
data = urlread2(url);
Now I save the data to a file and pass the filepath to the mex function. The IO is time-wasting. Is there a way to pass the data directly to the mex function without saving it to a temporary file (using Java class?)?

採用された回答

Walter Roberson
Walter Roberson 2015 年 9 月 7 日
urlread2 is from the File Exchange . It outputs a string, not a file. If you are writing to a file then that is in your own code.
If the mex requires a filename instead of a string, then change the mex. Or write to an solid state drive, or to a ramdisk.

その他の回答 (2 件)

Image Analyst
Image Analyst 2015 年 9 月 7 日
I don't think so. If the mex file was written to accept a text string that represents a filename, then you're stuck with that. If you want it to accept a numerical array then you'd have to rewrite the mex code to do that.

Guillaume
Guillaume 2015 年 9 月 7 日
There's nothing built into matlab for this and yes, it would be nice if matlab io supported streams instead of just concrete files.
The only way I can think to work around this (short of rewriting your mex so it does the url fetching itself) is to implement a ram drive.

カテゴリ

Help Center および File ExchangeExternal Language Interfaces についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by