Trouble in codegen customized antenna pattern
4 views (last 30 days)
Show older comments
Tor Viscor on 6 May 2021
Commented: Tor Viscor on 11 May 2021
I am trying to use codegen on a customized antenna pattern, basically this,
pattern = phased.CustomAntennaElement('AzimuthAngles',x.azim,'ElevationAngles',x.elev, ...
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?
Honglei Chen on 8 May 2021
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.
Honglei Chen on 7 May 2021
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()
AzimuthAngles = -180:180;
ElevationAngles = -90:90;
MagnitudePattern = coder.const(getPattern(AzimuthAngles,ElevationAngles));
phasepattern = zeros(size(MagnitudePattern));
ant = phased.CustomAntennaElement('AzimuthAngles',AzimuthAngles,'ElevationAngles',ElevationAngles, ...
pattern = ant(3e8,[0;0]);
The supporting function, which needs to be on path, looks like below
function pat = getPattern(AzimuthAngles,ElevationAngles)
pat = mag2db(repmat(cosd(ElevationAngles)', ...
The codegen command is shown below
>> codegen phasedArrayWrapper
Code generation successful.
Find more on Direction of Arrival Estimation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!