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

1 Ansicht (letzte 30 Tage)
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 Kommentare
Xuechu Xu
Xuechu Xu am 21 Jun. 2018
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 am 21 Jun. 2018
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by