Trouble in codegen customized antenna pattern

조회 수: 2 (최근 30일)
Tor Viscor 2021년 5월 6일
댓글: Tor Viscor 2021년 5월 11일
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이전 댓글 -1개 표시이전 댓글 -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
댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Tor Viscor 2021년 5월 11일
Thanks for the answer.
I tried your way and also something similar,by saving the pattern information in a variable and loaded it in the main code for codegen. But both resulted in that error message. Could it be an issue with the pattern type I am trying to use in the custom antenna function?
% this is the pattern to be used in the custom antenna element function, saved in 'cosVar'
antenna = phased.CosineAntennaElement;
TRM = phased.ULA('NumElements',6,'Element',antenna,'ArrayAxis','y','ElementSpacing',lambda/2);
[pat_azEl,azim, elev ] = pattern(TRM,fc,-180:0.05:180,-90:0.05:90);
save('cosVar.mat','pat_azEl','azim','elev');
*************************************************************
TRM_pattern = phased.CustomAntennaElement('AzimuthAngles',azim,'ElevationAngles',elev,'MagnitudePattern',(pat_azEl),'PhasePattern',0*ones(size(pat_azEl)));

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Antennas, Microphones, and Sonar Transducers에 대해 자세히 알아보기

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by