Trouble in codegen customized antenna pattern
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I am trying to use codegen on a customized antenna pattern, basically this,
pattern = phased.CustomAntennaElement('AzimuthAngles',x.azim,'ElevationAngles',x.elev, ...
'MagnitudePattern',(x.pat_azEl),'PhasePattern',45*ones(size(x.pat_azEl)));
but I keep getting the following error message:
"??? Expression could not be reduced to a constant.", which points to line 1014 of the CustomAntennaElement.m function when setting the phase.
Does Matlab Coder not support custom antenna functions? Could anybody give me some advice please?
1 个评论
Honglei Chen
2021-5-8
Thansk for reporting this. We've idenfitied the issue and will fix it in a future release. Please see the ansewr below for a workaround.
回答(1 个)
Honglei Chen
2021-5-7
I don't know how x is formed, but here is an example you can take a look, that generates the code. The main idea is to push pattern computation to a separate function and use coder.extrinsic to compute it first then save as a constant.
The main function looks like this
function pattern = phasedArrayWrapper()
coder.extrinsic('getPattern');
AzimuthAngles = -180:180;
ElevationAngles = -90:90;
MagnitudePattern = coder.const(getPattern(AzimuthAngles,ElevationAngles));
phasepattern = zeros(size(MagnitudePattern));
ant = phased.CustomAntennaElement('AzimuthAngles',AzimuthAngles,'ElevationAngles',ElevationAngles, ...
'MagnitudePattern',MagnitudePattern,'PhasePattern',phasepattern);
pattern = ant(3e8,[0;0]);
end
The supporting function, which needs to be on path, looks like below
function pat = getPattern(AzimuthAngles,ElevationAngles)
pat = mag2db(repmat(cosd(ElevationAngles)', ...
1,numel(AzimuthAngles)));
end
The codegen command is shown below
>> codegen phasedArrayWrapper
Code generation successful.
HTH
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!