FileID pass as function argument for Matlab Coder gen

1 回表示 (過去 30 日間)
Lukai Cai
Lukai Cai 2018 年 2 月 28 日
コメント済み: Denis Gurchenkov 2018 年 2 月 28 日
I need to generate a function with FileID as argument. The matlab code looks like this:
outfileId = fopen('test_c.csv', 'w'); func1(outfileId);
when generate the C++ using Matlab Coder, it automatically recognize the argument type as double. And the generated C++ is something like this: func1(double outfileId){ FILE * filestar; getfilestar(outfileId, &filestar, &autoflush); .. using filestar for file processing. }
My question is: how do I assign the value when I call func1 in my manually modeled C++. (e.g. need reverse function of getfilestar).
( Currently, I manually update the generated code by commenting out getfilestar and directly passing filestar as argument. And it works)
Thanks a lot!
  1 件のコメント
Denis Gurchenkov
Denis Gurchenkov 2018 年 2 月 28 日
Likai, if you want to call func1 from your hand-written C++ code, then you should have two entry-point matlab functions when generating code. One function would return the double that corresponds to file handle, and the other one would take a double as an input, and call func1.
So your C++ code first calls the first entry point to open the file, gets the double value, and then passes it to the 2nd entry pont.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by