Matlab coder - When input a filename as input paremeter, how to define input types
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
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!