I understand that you wanted to create antenna object with a custom gain setting. As the gain property is typically a result of the physical dimensions and operating frequency of the antenna, you can optimize these parameters using 'optimize' function of MATLAB’s Antenna Toolbox.
It optimizes the antenna or the array at the specified frequency, using a specified objective function, antenna or array properties and their bounds.
% Define the operating frequency
frequency = 900e6;
% Design the initial horn antenna at the specified frequency
Hornantenna = design(horn, frequency);
% Define the design variables and their bounds
designVariables = {'FlareLength', 'FlareHeight'};
XVmin = [0.001, 0.001];
XVmax = [0.1, 0.1];
% Set the constraints for gain
constraints = {'Gain < 7.01'};
% Optimize the antenna to maximize gain
HornOpt = optimize(Hornantenna, frequency, "maximizeGain", designVariables, {XVmin; XVmax}, ...
Constraints=constraints, Iterations=10);
HornOpt
You can modify any simulation parameter in the above code as needed. You can use the optimized antenna object for further analysis. Alternatively, you can utilize the ‘AntennaDesigner’ app in MATLAB by clicking the following icon to visually adjust and optimize the antenna properties.
For more detailed information, refer to the MATLAB R2023b documentation on the 'optimize' function:
Hope this helps!