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

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 Kommentare

From your screenshot, you appear to have modified the Antenna Model Generation and Full-Wave Analysis From A Photo example, as your workspace does not have all the same variables it should if you were running the example. Please share all your code as well as your antenna image. You can attach them to your post using the paperclip icon.
Below content of the command window - not all text concerning the transformation from a 4000dpi .tiff file have been preserved. (I have tried to translate from a Corel Designer file to .stl file, but have not been able to preserve geometry intact - so this try with converting to .tif 4000dpi image, which should be easy to get a clear boundary from),
Please note that I do not know - yet (hopfully) - how to save the code as I as mentioned have been fumbling forward, feeling the example have been omitting some important steps - which I expect will be self-evident for the author.
Kind regards - AND THANKS IN ADVANCE !!!!
Jan Borst
Did you mean:
>> B = bwboundaries(BW1);
>> 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')
Unrecognized function or variable 'xmax'.
Did you mean:
>> >> B = bwboundaries(BWf);
xmax = max(B{1}(:,1));
xmin = min(B{1}(:,1));
ymax = max(B{1}(:,2));
ymin = min(B{1}(:,2));
>> B = bwboundaries(BWf);
Invalid use of operator.
>> B = bwboundaries(BW1);
xmax = max(B{1}(:,1));
xmin = min(B{1}(:,1));
ymax = max(B{1}(:,2));
ymin = min(B{1}(:,2));
>> 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')
>> pol=antenna.Polygon(´Vertices´,Bp{1});
pol=antenna.Polygon(´Vertices´,Bp{1});
Error: Invalid text character. Check for unsupported symbol, invisible character, or pasting of non-ASCII
characters.
>> pol=antenna.Polygon(`Vertices`,Bp{1});
pol=antenna.Polygon(`Vertices`,Bp{1});
Error: Invalid text character. Check for unsupported symbol, invisible character, or pasting of non-ASCII
characters.
>> pol=antenna.Polygon('Vertices',Bp{1});
>> show(pol)
>> rect1 = antenna.Rectangle('Length', 1e-3, 'Width', 0.5e-3, ...
'Center', [0.0045 0.00073]);
>> final_shape = pol+rect1;
>> show(final_shape)
>> rect1 = antenna.Rectangle('Length', 0.5e-3, 'Width', 0.1e-3, ...
'Center', [0.0045 0.00073]);
>> final_shape = pol+rect1;
>> show(final_shape)
>> p = pcbStack;
p.Layers = {final_shape};
p.BoardShape = antenna.Rectangle('Length',1,'Width',1);
p.FeedLocations = [0.0045 0.00073] 1 ];
p.FeedDiameter = 1.25e-4;
show(p);
p.FeedLocations = [0.0045 0.00073] 1 ];
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax
error. To construct matrices, use brackets instead of parentheses.
>> p = pcbStack;
p.Layers = {final_shape};
p.BoardShape = antenna.Rectangle('Length',1,'Width',1);
p.FeedLocations = [0.0045 0.00073];
p.FeedDiameter = 1.25e-4;
show(p);
Error using pcbStack/set.FeedLocations (line 396)
FeedLocations must be described by either 3,or 4 column matrices as: [x,y,startLayer], [x,y,startLayer stopLayer]
>> p.Layers = {final_shape};
p.BoardShape = antenna.Rectangle('Length',1,'Width',1);
p.FeedLocations = [0.0045, 0.00073, 1];
p.FeedDiameter = 1.25e-4;
show(p);
>> show(p);
>> f_coarse = linspace(0.8e9,0.95e9,21);
figure
impedance(p,f_coarse)
Index exceeds the number of array elements. Index must not exceed 6.
Error in antenna.Shape/fillFeatureHoleInMesh (line 1270)
holeTriangles = [holeTriangles;ia(trhole.ConnectivityList)]; %#ok<AGROW>
Error in antenna.Shape/meshGenerator (line 1143)
[p,t] = fillFeatureHoleInMesh(obj,p,t);
Error in antenna.Shape/parseNewMesherInputs (line 1485)
meshGenerator(obj,defaultHmax,defaultGrowthRate,defaultHmin,...
Error in antenna.Shape/mesh (line 965)
parseNewMesherInputs(obj,varargin{:});
Error in em.PCBStructures/runMeshGeneratorForEachLayer
Error in pcbStack/meshGenerator (line 1199)
runMeshGeneratorForEachLayer(obj,tempMetalLayers, ...
Error in em.MeshGeometry/updateMeshForPcbStack
Error in em.MeshGeometry/updateMesh
Error in em.MeshGeometry/getMesh
Error in em.EmStructures/analyze
Error in em.PortAnalysis/impedance (line 157)
status = analyze(obj,freq);
>> f_coarse = linspace(0.8e9,0.95e9,21);
figure
impedance(p,f_coarse)
Index exceeds the number of array elements. Index must not exceed 6.
Error in antenna.Shape/fillFeatureHoleInMesh (line 1270)
holeTriangles = [holeTriangles;ia(trhole.ConnectivityList)]; %#ok<AGROW>
Error in antenna.Shape/meshGenerator (line 1143)
[p,t] = fillFeatureHoleInMesh(obj,p,t);
Error in antenna.Shape/parseNewMesherInputs (line 1485)
meshGenerator(obj,defaultHmax,defaultGrowthRate,defaultHmin,...
Error in antenna.Shape/mesh (line 965)
parseNewMesherInputs(obj,varargin{:});
Error in em.PCBStructures/runMeshGeneratorForEachLayer
Error in pcbStack/meshGenerator (line 1199)
runMeshGeneratorForEachLayer(obj,tempMetalLayers, ...
Error in em.MeshGeometry/updateMeshForPcbStack
Error in em.MeshGeometry/updateMesh
Error in em.MeshGeometry/getMesh
Error in em.EmStructures/analyze
Error in em.PortAnalysis/impedance (line 157)
status = analyze(obj,freq);
>> f_coarse = linspace(0.8e9,0.95e9,6);
figure
impedance(p,f_coarse)
Index exceeds the number of array elements. Index must not exceed 6.
Error in antenna.Shape/fillFeatureHoleInMesh (line 1270)
holeTriangles = [holeTriangles;ia(trhole.ConnectivityList)]; %#ok<AGROW>
Error in antenna.Shape/meshGenerator (line 1143)
[p,t] = fillFeatureHoleInMesh(obj,p,t);
Error in antenna.Shape/parseNewMesherInputs (line 1485)
meshGenerator(obj,defaultHmax,defaultGrowthRate,defaultHmin,...
Error in antenna.Shape/mesh (line 965)
parseNewMesherInputs(obj,varargin{:});
Error in em.PCBStructures/runMeshGeneratorForEachLayer
Error in pcbStack/meshGenerator (line 1199)
runMeshGeneratorForEachLayer(obj,tempMetalLayers, ...
Error in em.MeshGeometry/updateMeshForPcbStack
Error in em.MeshGeometry/updateMesh
Error in em.MeshGeometry/getMesh
Error in em.EmStructures/analyze
Error in em.PortAnalysis/impedance (line 157)
status = analyze(obj,freq);
>> p = Ø9;
impedance (h,80e6:1e6:1000e6);
p = Ø9;
Error: Invalid text character. Check for unsupported symbol, invisible character, or pasting of non-ASCII
characters.
>> p = Z9;
impedance (h,80e6:1e6:1000e6);
Unrecognized function or variable 'Z9'.
>> p = p;
impedance (h,80e6:1e6:1000e6);
Unrecognized function or variable 'h'.
>> p = p;
impedance (80e6:1e6:1000e6);
Check for incorrect argument data type or missing argument in call to function 'impedance'.
>>
impedance (p,80e6:1e6:1000e6);
Index exceeds the number of array elements. Index must not exceed 6.
Error in antenna.Shape/fillFeatureHoleInMesh (line 1270)
holeTriangles = [holeTriangles;ia(trhole.ConnectivityList)]; %#ok<AGROW>
Error in antenna.Shape/meshGenerator (line 1143)
[p,t] = fillFeatureHoleInMesh(obj,p,t);
Error in antenna.Shape/parseNewMesherInputs (line 1485)
meshGenerator(obj,defaultHmax,defaultGrowthRate,defaultHmin,...
Error in antenna.Shape/mesh (line 965)
parseNewMesherInputs(obj,varargin{:});
Error in em.PCBStructures/runMeshGeneratorForEachLayer
Error in pcbStack/meshGenerator (line 1199)
runMeshGeneratorForEachLayer(obj,tempMetalLayers, ...
Error in em.MeshGeometry/updateMeshForPcbStack
Error in em.MeshGeometry/updateMesh
Error in em.MeshGeometry/getMesh
Error in em.EmStructures/analyze
Error in em.PortAnalysis/impedance (line 157)
status = analyze(obj,freq);
>> showgrid
Unrecognized function or variable 'showgrid'.
>> show(p)
>> f_coarse = linspace(0.8e9,0.95e9,5);
figure
impedance(p,f_coarse)
Index exceeds the number of array elements. Index must not exceed 6.
Error in antenna.Shape/fillFeatureHoleInMesh (line 1270)
holeTriangles = [holeTriangles;ia(trhole.ConnectivityList)]; %#ok<AGROW>
Error in antenna.Shape/meshGenerator (line 1143)
[p,t] = fillFeatureHoleInMesh(obj,p,t);
Error in antenna.Shape/parseNewMesherInputs (line 1485)
meshGenerator(obj,defaultHmax,defaultGrowthRate,defaultHmin,...
Error in antenna.Shape/mesh (line 965)
parseNewMesherInputs(obj,varargin{:});
Error in em.PCBStructures/runMeshGeneratorForEachLayer
Error in pcbStack/meshGenerator (line 1199)
runMeshGeneratorForEachLayer(obj,tempMetalLayers, ...
Error in em.MeshGeometry/updateMeshForPcbStack
Error in em.MeshGeometry/updateMesh
Error in em.MeshGeometry/getMesh
Error in em.EmStructures/analyze
Error in em.PortAnalysis/impedance (line 157)
status = analyze(obj,freq);
>> Index exceeds the number of array elements. Index must not exceed 6.
Check for incorrect argument data type or missing argument in call to function 'Index'.
>>
>>
>>
>> mesh(final_shape, 0.01)
>> p = pcbStack;
p.Layers = {final_shape};
p.BoardShape = antenna.Rectangle('Length',1,'Width',1);
p.FeedLocations = [0.0045 0.00073] 1 ];
p.FeedDiameter = 1.25e-4;
p.FeedLocations = [0.0045 0.00073] 1 ];
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax
error. To construct matrices, use brackets instead of parentheses.
>> p.Layers = {final_shape};
p.BoardShape = antenna.Rectangle('Length',1,'Width',1);
p.FeedLocations = [0.0045, 0.00073, 1];
p.FeedDiameter = 1.25e-4;
show(p);
>> p.Layers = {final_shape};
p.BoardShape = antenna.Rectangle('Length',1,'Width',1);
p.FeedLocations = [0.0045, 0.00073, 1];
p.FeedDiameter = 1.25e-4;
show(p);
>> mesh(final_shape, 0.01)p.Layers = {final_shape};
p.BoardShape = antenna.Rectangle('Length',1,'Width',1);
p.FeedLocations = [0.0045, 0.00073, 1];
p.FeedDiameter = 1.25e-4;
show(p);
mesh(final_shape, 0.01)p.Layers = {final_shape};
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax
error. To construct matrices, use brackets instead of parentheses.
Did you mean:
>> mesh(final_shape, 0.01)
>>
"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.
Strictly from an archiving perspective, may I suggest you edit your original post to state
"I am a bleeding newbie with MATLAB . . ."
:)

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

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 Kommentare

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);
I want to thank you for a quick and very constructive answer - you have been a real help !
Jan Borst

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Properties finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by