Clear Filters
Clear Filters

When finding impedance of "2D" antenna I get error : Index exceeds the number of array elements. Index must not exceed 6.

6 views (last 30 days)
I am a bleeding newbie with Mathcad and have fumbled me to the breaking point in example :
Antenna Model Generation and Full-Wave Analysis From A Photo
wher I should be able to get an impedance graph. Then I get this error message - please can anybody help me to find out what is wrong ??
Kind regards
Jan Borst
  4 Comments
Cris LaPierre
Cris LaPierre on 30 Jan 2022
"Please note that I do not know - yet (hopfully) - how to save the code as I as mentioned have been fumbling forward,"
You would be well served by taking the time to go through MATLAB Onramp and/or perhaps something a little more thorough, like our MATLAB Essentials course on edX.
Raymond Norris
Raymond Norris on 31 Jan 2022
Strictly from an archiving perspective, may I suggest you edit your original post to state
"I am a bleeding newbie with MATLAB . . ."
:)

Sign in to comment.

Accepted Answer

Cris LaPierre
Cris LaPierre on 30 Jan 2022
In MATLAB, run the following command to see the script for the example you are trying to follow.
openExample('antenna/AntennaModelGenerationAndFullWaveAnalysisFromAPhotoExample')
Make a copy of the script (File > Save As) and modify the code in the example script to process your file. By working in a script, your code is saved, making it easier to rerun the code. This is a much better way to develop code for anything you may want to reuse.
  2 Comments
Cris LaPierre
Cris LaPierre on 30 Jan 2022
Edited: Cris LaPierre on 30 Jan 2022
Doing what I suggested, below is an updated example code that runs with your parameters Doing some comparison between your antenna and the one in the example, I discovered that your error was because your p.FeedDiameter was too large. I reduced it to about half the width of the rectange it is placed on (0.5e-4).
While I would not be ready to say it is correct just yet, this will allow you to start focusing on your antenna rather than fixing errors.
Don't worry about the red below the code. That's a result of running the code here on the Answers platform. You will not get that when you run it on your computer.
unzip('NFmicro.zip');
%% Antenna Model Generation and Full-Wave Analysis From A Photo
% This example demonstrates the process of using a photograph of a planar
% antenna to generate a viable antenna model and its subsequent analysis
% for port, surface and field characteristics. The Image Segmenter app
% will be used to perform segmentation on the image of an RFID tag, and the
% resulting boundaries will be used to set up the antenna model in Antenna
% Toolbox(TM). An initial impedance analysis will be done over a frequency
% range to understand the port characteristics of the antenna. After
% determining the resonance frequency, the current and far-field pattern
% will be calculated and plotted.
%
%
% * This example depends on Image Processing Toolbox(TM)
%
% Copyright 2017 The MathWorks, Inc.
%% Boundary Clean-up
% _Read Image, Create Mask and Visualize_
%
% The image of the RFID tag is imported into the workspace and the boundary
% is generated by using the exported code from the Image Segmenter app.
I = imread('NFmicro.tif');
BWf = imcomplement(I);
figure
imshow(BWf)
%% Calculate Boundaries in Cartesian Space
% For performing full-wave analysis on this structure the next step is to
% convert the pixel space representation of the boundary to a cartesian
% space representation. To do this we extract the maximum and minimum pixel
% indices in the x, y dimensions and scale it based on overall tag
% dimensions in terms of its length and width.
%
B = bwboundaries(BWf);
xmax = max(B{1}(:,1));
xmin = min(B{1}(:,1));
ymax = max(B{1}(:,2));
ymin = min(B{1}(:,2));
% Scale per pixel based on tag dimensions
L = 9e-3;
W = 9e-3;
LperColpixel = L/(xmax-xmin);
WperRowpixel = W/(ymax-ymin);
Bp = B;
for i = 1:length(Bp)
Bp{i} = [Bp{i}(:,1).*LperColpixel Bp{i}(:,2).*WperRowpixel zeros(size(Bp{i},1),1)];
end
p = cell2mat(Bp);
x = p(:,1);
y = p(:,2);
figure
plot(x,y,'*')
grid on
axis equal
xlabel('x (m)')
ylabel('y (m)')
title('Boundary points')
%%
% _Reduce Boundary Points_
%
% The boundary has 28000 points, and this will result in a very large mesh
% size. Downsample this boundary by a factor of 39. The downsample factor
% was chosen since it still represented the boundary details accurately
% based on a simple visual inspection.
D = 39;
xD = x(1:D:end);
yD = y(1:D:end);
BpD{1} = Bp{1}(1:D:end,:);
figure
hold on
plot(xD,yD,'r*')
shg
grid on
axis equal
%% Create Layer For PCB Stack
% Create a shape from the boundary
pol = antenna.Polygon('Vertices',BpD{1});
%%
% Creating the Antenna Feed
% The feed region of the tag still has some sharp artifacts in the
% boundary. This must be cleaned up prior to defining the feed. We use
% a boolean subtract operation is done by creating a rectangle
% to remove this artifact.
rect1 = antenna.Rectangle('Length', 0.5e-3, 'Width', 0.1e-3, ...
'Center', [0.0045 0.00073]);
%%
% Resultant shape
final_shape = pol+rect1;
%% Create a PCB Stack
% Assign the resultant shape generated as the layer for pcb stack. FeedLocation
% is specified appropriately so that it lies on this layer
p = pcbStack;
p.Layers = {final_shape};
p.BoardShape = antenna.Rectangle('Length',1,'Width',1);
p.FeedLocations = [0.0045 0.00073 1 ];
p.FeedDiameter = 0.5e-4;
show(p);
%% Port Analysis - Impedance Behavior vs. Frequency
% Determine the port characteristics of this antenna by executing an
% impedance analysis over a coarse sampled frequency range. The tag is
% expected to operate in the UHF band, between 800 - 900 MHz. Our frequency
% range will extend slightly past 900 MHz.
%
f_coarse = linspace(0.8e9,0.95e9,21);
figure
impedance(p,f_coarse)
%% Tuning the Tag for Resonance
% The tag is inductive and has a good resistive component at approximately
% 854 MHz. Moreover the reactance shows the classic parallel resonance curve
% around that frequency. Typically, the input impedance of the chip would
% be complex, to match to the tag. Use Load property on the antenna to
% cancel the inductive component. Since the reactance is about 200 $\Omega$
% create a load with reactance of -200 $\Omega$ and add it to the antenna
% model.
X = -1i*200;
zl = lumpedElement;
zl.Impedance = X;
p.Load = zl;
%%
% Recalculate impedance
% With the load in place at the feed, the inductive part of the reactance
% should be canceled at 854 MHz. Confirm this by analyzing the impedance
% over a fine frequency range. The reactance at 854 MHz should be
% approximately 0 ohms.
f_fine = linspace(0.8e9,0.95e9,51);
figure
impedance(p,f_fine)
%% Surface Analysis - Current behavior at Center Frequency
% At the center frequency visualize the current distribution on the antenna
% surface.
%
figure
current(p,854e6,'scale','log10');
view(0,90);
%% Field Analysis - Pattern at Center Frequency
% RFID tags typically have an omnidirectional far-field pattern in one
% plane. Visualize the far-field radiation pattern of the tag.
%
figure
pattern(p,854e6)
Error using uilabel (line 36)
Functionality not supported with figures created with the figure function.

Error in em.internal.addtextinfo

Error in em.FieldAnalysisWithFeed/pattern (line 235)
em.internal.addtextinfo(gcf, tab1, tab3, tab2);

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with Antenna Toolbox 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!