フィルターのクリア

Matlab coder - When input a filename as input paremeter, how to define input types

2 ビュー (過去 30 日間)
Xuechu Xu
Xuechu Xu 2018 年 6 月 20 日
コメント済み: Adam 2018 年 6 月 21 日
Hello, I wonder how could I set the filename as a input parameter? I am using Matlab coder to generate a c++ function, the input parameter is the filename of a image file. I called the parameter in "imread()".
When I use "Autodefine Input Types", the autodefined type is char(1x9) or char(1x:9), which is of course wrong because I can't promise that the length of other filename is smaller than 9.
Then I wanna change the input type to "string(1x1)", the app automatically add a sub-type, like shown in picture below.
According to the request of the app, this sub-type can only be defined as "char", so I choose char(1x1).
Then it goes wrong when generating trial code, saying "The filename or URL must be char vector."
I wonder how could I set the filename as a input parameter? Or if I use char(1xinf) as a input type, how should I define the input parameter in C++ program?(I tried char s[] but faild). Thank you!
  3 件のコメント
Xuechu Xu
Xuechu Xu 2018 年 6 月 21 日
Actually I don't know aobut it, I thought it might be like a malloc command in C file. Do you know how to solve this problem for defining a string with undetermined length as function input? Thank you!
Adam
Adam 2018 年 6 月 21 日
I don't generally pass strings into a Coder app so that is why I was asking if 1xInf isn't an option. It is for doubles so I don't see why it wouldn't be for chars too, though I guess you may want to pass in a variable with the actual length of it also so the C code knows how long it is.

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

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by