Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

acessing structure data from an embedded matlab function using s-function

1 vue (au cours des 30 derniers jours)
arun kumar
arun kumar le 6 Mar 2015
Clôturé : MATLAB Answer Bot le 20 Août 2021
i am transmitting a structure data which has around 500 elements(but it varies so i also need to find out the number of input fields of the structure) all of which are of different data types (uint8,unit16,uint32,single). first to transmit this structure i created a bus object and then transmitted them using the embedded matlab function. now i need to separate the individual signals (like flattening the structure) in the output. i can use a bus selector and do this but instead i want to use an s-function. so i used an s-function builder (and not the normal s-function block) block and tried to access the first two signals using
y0[0]=u0->speed; y1[0]=u0->yaw_rate;
but i want to use a loop to actually allocate the individual inputs to separate outputs. For this i need to know the number of inputs, its datatype and its fieldname.Is it possible?
I was going through the documentation and came accross stuff like mxGetFieldNameByNumber and mxGetNumberOfFields but i just don't know how to use these inside a s-function builder. Or if its possible to write a normal mex code using normal s-function block then how to add the bus-elements to this s-function C file.
Or Am i approaching the whole problem completely wrong? is there a way to transmit a structure or a cell array other than using this method and without creating a bus element?

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by