i need an idea how to make an s-function behave as a bus selector. i have an structure being given as a input to an s-function . this structure has 283 elements (maybe more in future) and is being supplied as a bus. i want the s-function to output the individual elements of the structure (and thus act like a bus selector). Ofcourse I can do this easily with manual typing :
y0[0]=u0->arguemtn;
y0[0]=u0->speedx; % and so on till 283
but then i need to know the name of the all the structure element and also need to enter them manually. is there a way i just need to use a simple for loop and allocate individual element inputs to outputs of the s-function.
you can just give me the hint since i am just stuck here
UPDATE
after the suggested answer i tried to write something like this.
int number_of_elements,i;
char field_name;
number_of_elements= mxGetNumberOfFields(u0[0]);
for(i=0;i<number_of_elements;i++)
{
field_name=mxGetFieldNameByNumber(u0[0], i);
yi[0]=u0->field_name;
}
but first how can i make y1 y2 y3 and so on as a part of the loop. ofcourse i can't write yi since its an entirely different variable. also this part I have written in the Code Description part of the s-function builder which I think is wrong again. can anybody suggest me what i should do exactly.
another important point is that I am sending the structure with fields which are of different datatypes (like uint8,uint16,single) and thus i also need to determine the input datatype. how can that be possible and how i can set this datatype to my output in a loop?