www.gusucode.com > phased 案例源码 matlab代码程序 > phased/AntennaWithCustomRadiationPatternExample.m

    %% Antenna with Custom Radiation Pattern
% This example shows how to construct a custom antenna element object. The
% radiation pattern is independent of azimuth angle and has a cosine
% dependence on elevation angle.
%%
% *Note:* This example runs only in R2016b or later. If you are using an earlier
% release, replace each call to the function with the equivalent |step|
% syntax. For example, replace |myObject(x)| with |step(myObject,x)|.
az = -180:90:180;
el = -90:45:90;
elresp = cosd(el);
antenna = phased.CustomAntennaElement('AzimuthAngles',az,...
    'ElevationAngles',el,...
    'RadiationPattern',repmat(elresp',1,numel(az)));
%%
% Show the radiation pattern.
disp(antenna.RadiationPattern)
%%
% Calculate the antenna response at the azimuth-elevation pairs _(-30,0)_
% and _(-45,0)_ at 500 Mhz.
ang = [-30 0; -45 0];
resp = antenna(500e6,ang);
disp(resp)
%%
% The following code illustrates how nearest-neighbor interpolation method is used
% to find the antenna voltage response in the two directions. The total
% response is the product of the angular response and the frequency
% response.
g = interp2(deg2rad(antenna.AzimuthAngles),...
    deg2rad(antenna.ElevationAngles),...
    db2mag(antenna.RadiationPattern),...
    deg2rad(ang(1,:))', deg2rad(ang(2,:))','nearest',0);
h = interp1(antenna.FrequencyVector,...
    db2mag(antenna.FrequencyResponse),500e6,'nearest',0);
antresp = h.*g;
%%
% Compare the value of |antresp| to the output of the |step| method.
disp(antresp)