微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > 天线设计讨论 > 求助:关于MATLAB的问题

求助:关于MATLAB的问题

时间:10-02 整理:3721RD 点击:
我最近在看《通信天线建模与MATLAB仿真分析》这本书,第7章有个多带天线Sierpinski蝴蝶结天线的仿真,可是我用书中配套的MATLAB程序仿真出的天线模型却与书上不一样(莫名其妙少了2个小三角),看了半天也看不出程序哪里出了问题,希望有人能帮帮我,提前谢谢了!
clear all
%Geometry data
S=2;                    %Stage of fractal growth
SM=5;                   %Stage of mesh growth
h=0.1;                  %Half-height of bowtie
flareangle=(0.5)*pi;    %Bowtie flare angle
TAN=tan(flareangle/2);
%Identify vertex points
Count=1;
for s=1:SM^2
    StepY=h/(SM^2-1);
    y=(s-1)*StepY;
    fuzzy=1-0.0001*s;
    for ss=1:s
        StepX=2*StepY*TAN;
        x=-y*TAN+StepX*(ss-1);
        X(Count)=x*fuzzy;
        Y(Count)=y;
        Count=Count+1;
    end
end
%Create mesh triangles
p=[X; Y; zeros(1,length(X))];
TRI = delaunay(X,Y);
t=TRI';
TrianglesTotal=length(t);
for m=1:length(t)
    n1=t(1,m); n2=t(2,m); n3=t(3,m);      
    Center(:,m)=1/3*(p(:,n1)+p(:,n2)+p(:,n3));
end
%Create fractal triangles
%Initial triangle
ArrayOfTrianglesX(:,1)=[-h*TAN 0 h*TAN]';
ArrayOfTrianglesY(:,1)=[h 0 h]';
CatPolygonX=[];
CatPolygonY=[];
for s=1:S
    Length=length(ArrayOfTrianglesX(1,:));
    ArrayOfTrianglesX1=[];
    ArrayOfTrianglesY1=[];
    for i=1:Length
        InpX=ArrayOfTrianglesX(:,i);
        InpY=ArrayOfTrianglesY(:,i);
        [CatX, CatY, T1X, T1Y, T2X, T2Y, T3X, T3Y]=divider(InpX, InpY, TAN);
        CatPolygonX=[CatPolygonX CatX];
        CatPolygonY=[CatPolygonY CatY];
        ArrayOfTrianglesX1=[ArrayOfTrianglesX1 T1X T2X T3X];
        ArrayOfTrianglesY1=[ArrayOfTrianglesY1 T1Y T2Y T3Y];
    end
    ArrayOfTrianglesX=ArrayOfTrianglesX1;
    ArrayOfTrianglesY=ArrayOfTrianglesY1;   
end
Length=length(CatPolygonX(1,:));
ING=zeros(1,length(t));
for i=1:Length
    ING = ING+inpolygon(Center(1,:), Center(2,:), CatPolygonX(:,i),CatPolygonY(:,i));
end
%Triangles to remove
for i=1:Length
    IN      =inpolygon(Center(1,:), Center(2,:), CatPolygonX(:,i),CatPolygonY(:,i));
    Index   =find(IN==1);
    Array  =sqrt((Center(1,Index)-CatPolygonX(1,i)).^2+(Center(2,Index)-CatPolygonY(1,i)).^2);
    [Y,I]=min(Array);
    ING(Index(I))=0;
    Array  =sqrt((Center(1,Index)-CatPolygonX(2,i)).^2+(Center(2,Index)-CatPolygonY(2,i)).^2);
    [Y,I]=min(Array);
    ING(Index(I))=0;
    Array  =sqrt((Center(1,Index)-CatPolygonX(3,i)).^2+(Center(2,Index)-CatPolygonY(3,i)).^2);
    [Y,I]=min(Array);
    ING(Index(I))=0;
end
%Remove unnecessary triangles
TrianglesTotal=length(t);
Triangle=[];
for m=1:TrianglesTotal
   if(ING(m)==0)
        Triangle=[Triangle t(:,m)];
   end
end
clear t;
t=Triangle(:,2:length(Triangle)); %first triangle is removed
TrianglesTotal=length(t);
t(4,:)=1;
%Add mirror image to structure
p(2,:)=p(2,:)-StepY;
pbase=-p; tbase=t;
t=[tbase t+length(pbase)]; t(4,:)=1;
p=[pbase p];
%Eliminate equal points
length(p)
P(1:3,1)=p(1:3,1);
for L=2:length(p)
   [M,N]=size(P);
   Point=p(1:3,L);
   Index=find(abs(sum(abs(P-repmat(Point,1,N))))<1.e-9);
   if (isempty(Index))
       P=[P Point];
   end 
end
length(P)
%Re-enumerate triangle points
[M,N]=size(P);
for L=1:length(t);
    n=t(:,L);
    for i=1:3
        Index=find(abs(sum(abs(P-repmat(p(1:3,n(i)),1,N))))<1.e-9);
        if(isempty(Index))
            t(i,L)=Index;
        end
    end
    t(4,L)=1;
end
clear p; p=P;
%Save result
save fractal p t;
viewer fractal
view(0,90)
上面的程序调用下面的函数
function [CatX, CatY, T1X, T1Y, T2X, T2Y, T3X, T3Y]=divider(InpX, InpY, TAN);
h=max(InpY)-min(InpY);
CenterX=0.5*(min(InpX)+max(InpX));
CenterY=0.5*(min(InpY)+max(InpY));
CatX=[-h/2*TAN 0 h/2*TAN]'+CenterX;
CatY=[ 0 h/2 0]'+CenterY;
T1X=[-h*TAN -h/2*TAN 0]'+CenterX;
T1Y=[h/2 0 h/2]'+CenterY;
T2X=[0 h/2*TAN h*TAN]'+CenterX;
T2Y=[h/2 0 h/2]'+CenterY;
T3X=[-h/2*TAN 0 h/2*TAN]'+CenterX;
T3Y=[0 -h/2 0]'+CenterY;

此贴已结。问题已经解决了,三角确错了位置。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top