Convert function with struct input to mex while number of fields is unknown
1 ビュー (過去 30 日間)
I am trying to translate a matlab function of mine into a mex function but I am facing some issues.
The problem is, that the input into my function is a struct with sub-structs, each containing the same amount of fields, but an unknown amount of fields.
Inside the function I check that with:
For MatLab that is no problem, but for mex it is a problem, since I have to declare the number of fields while generating it and there is no possibility to do this like with arrays where you can say "up to ..."
So if the field does not exist, the number of fields is unepexted for mex and it doesnt run.
Is there any workaround for this??
Just bypassing the struct and simply giving the field values as inputs for my function doenst work either, since the field and its values do not exist sometimes.
The only way would be to write the funtction multiple times and check the number of fields before and then call with an if statement the function with the right number of input arguments. But for me it seems unlikely that this is the best way to solve my problem.