MATLAB: Coder.extrinsic error! Radar designing

coder.extrinsicfmcwmatlab functionPhased Array System Toolboxradarsimulinkstruct

I am scanning an area from 0 to 45 degrees Azimuth using simulink blocks for FMCW radar. I used function block to write the code as was mentioned in radar scan example. The output of coder.extrinsic of phased.Radiator is mxarray and when I tried to assign it as follows I get an error " MATLAB expression 'phased.Radiator' is not of the correct class: expected 'struct', found 'phased.Radiator'". I preinitialized it already also. Same is the case with ant_array
coder.extrinsic('Phased.CosineAntennaElement','phased.Radiator','phased.URA');
sCos=phased.CosineAntennaElement('FrequencyRange', [35.5e9 36.5e9]);
hradiator=struct('Sensor', zeros(30), 'OperatingFrequency', fc);
hradiator=phased.Radiator('Sensor',sCos,'OperatingFrequency',fc);
ant_array = phased.URA('Element',sCos,'Size',[30 30],'ElementSpacing',[lambda/2, lambda/2]);
hradiator.Sensor = ant_array;

Best Answer

coder.extrinsic should have no effect in regular MATLAB. It only applicable when you try to generate the code. But I'm not sure what you are trying to achieve here. Once you are in codegen mode, if you set hradiator to struct and later assign a phased.Radiator class to it, then it is expected to error out because you now changed the type of hradiator.
HTH