passing struct object from matlab .m function to simulink embedded function
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I'd like to pass from a Matlab .m function a struct to a simulink MATLAB Function (%#codegen).
Just doing the following:
coder.extrinsic('createMainSensorCAN');
y = createMainSensorCAN();
gives the following error: "Function output 'y' cannot be an mxArray in this context. Consider preinitializing the output variable with a known type."
A sample of the struct being passed from the extrinsic function(it's to mimic a bus):
outputBuffer.Front_radar.('FRDDATAX').(token1).(token3) = zeros(sz,1);
The previous line works nicely in the Matlab function. Another thing about the buffer (outputBuffer) being passed to simulink is that it will be continually updated by the Matlab function and so I would like these updates to be propagated into the simulink model. I'm suspecting this might be a problem also, but have not gotten to that point yet.
I'm using 2011b
Any suggestions would be appreciated.
Thanks...
Mike
A followup:
When doing the following, it does not choke:
persistent myStructData;
if isempty(radarResimData)
[myStructData] = getStructData(); % expects back a fully populated struct
end
But when I add the following (y is declared an output of my embedded function) just after the new code above, I get the error message mentioned above:
y = myStructData
Am I to believe that embedded matlab cannot handle structs? I thought structs were similar in nature to buses?
FOLLOWUP II:
I have begun trying to do this with TsArrays. The discussion regarding these is quite sparse. Does anybody know where I can find a reference and/or a tutorial for TsArrays? Before answering that question, maybe the one to answer is, is this the preferred way to pass structs from the matlab domain to an embedded function in the simulink domain to be used as a bus?
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Event Functions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!