필터 지우기
필터 지우기

How to implement Array factor in MATLAB?

조회 수: 29 (최근 30일)
FARHA KHAN
FARHA KHAN 2021년 12월 5일
답변: ATHULRAJ 2023년 2월 27일
clc
clear all
close all
%arf of cca 4,16 ele
c=3*(10^8);
f=30*(10^9);
lambda=c/f;
l=[1 3] %mode
l = 1×2
1 3
r=[0.5 1.5]*lambda %radii of each ring
r = 1×2
0.0050 0.0150
k=(2*pi)/(lambda);
phio=0;
phi=0;
theta=0;
n=[4 16]; %no of ele
phi=[90:90:360 zeros(1,12); 22.5:22.5:360]
phi = 2×16
90.0000 180.0000 270.0000 360.0000 0 0 0 0 0 0 0 0 0 0 0 0 22.5000 45.0000 67.5000 90.0000 112.5000 135.0000 157.5000 180.0000 202.5000 225.0000 247.5000 270.0000 292.5000 315.0000 337.5000 360.0000
AF(1,1) = 0;
for m=1:2
for i=1:n(m)
AF(m,i)=exp((1j)*(((k)*(r(m))*(sin(deg2rad(theta)))*(cos(deg2rad(phi-phi(m,i))))+((l(m))*((-k)*r(m)*cos(deg2rad(phio-phi(m,i))))))));
end
end
Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 2-by-16.
Please help.

답변 (3개)

Walter Roberson
Walter Roberson 2021년 12월 5일
phi=[90:90:360 zeros(1,12); 22.5:22.5:360] is a 2 x 16 array.
AF(m,i)=exp((1j)*(((k)*(r(m))*(sin(deg2rad(theta)))*(cos(deg2rad(phi-phi(m,i))))+((l(m))*((-k)*r(m)*cos(deg2rad(phio-phi(m,i))))))));
The subtraction phi-phi(m,i) is taking all of phi and subtracting a scalar from it. That is going ot give you a 2 x 16 result because phi is 2 x 16. So the right hand side of the expression is going to be 2 x 16
Your formula defines AF(phi,I) where phi and I appear to be both M x N matrices. With your phi being 2 x 16 you should expect that the dimensions of AF should be 2 x 16 x (size of I) -- and that is after the double summation. Your code is not even doing the double summation.
  댓글 수: 4
Walter Roberson
Walter Roberson 2021년 12월 5일
Your existing code
for m=1:2
for i=1:n(m)
already does that, if m(1)=4 and m(2)=16 .
Note: the equation you posted is low resolution and difficult to read.
FARHA KHAN
FARHA KHAN 2021년 12월 5일
yeah but its not doing double summation

댓글을 달려면 로그인하십시오.


FARHA KHAN
FARHA KHAN 2021년 12월 5일
편집: Walter Roberson 2021년 12월 5일
AF= zeros(2,16);
for m=1:2
for i=1:n(m)
AF=AF+exp((1j)*(((k)*(r(m))*(sin(deg2rad(theta)))*(cos(deg2rad(phi-phi(m,i))))+ ((l(m))*((-k)*r(m)*cos(deg2rad(phio-phi(m,i))))))));
end
end
AFK=AF
is this right?
I am getting 16 ele but im supposed to get 20 @Walter Roberson
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 12월 5일
What leads you to expect to get 20 output elements when you are working with 2 x 16 arrays?
FARHA KHAN
FARHA KHAN 2021년 12월 5일
편집: FARHA KHAN 2021년 12월 5일
yeah
but 12 elements are zeros so i said 20 .
Now I am gettig right 2*16
clc
clear all
close all
%arf of cca 4,16 ele
c=3*(10^8);
f=30*(10^9);
lambda=c/f;
l=[1 3] %mode
r=[0.5 2.5]*lambda %radii of each ring
k=(2*pi)/(lambda);
phio=0;
phi=0;
theta=0;
n=[4 16]; %no of ele
phi=[90:90:360 zeros(1,12); 22.5:22.5:360]
AF= zeros(2,16);
for m=1:2
for i=1:n(m)
AF=AF+exp((1j)*(((k)*(r(m))*(sin(deg2rad(theta)))*(cos(deg2rad(phi-phi(m,i))))+ ((l(m))*((-k)*r(m)*cos(deg2rad(phio-phi(m,i))))))));
end
end
AFK=AF
By this code
Just can you check if it is right? @Walter Roberson

댓글을 달려면 로그인하십시오.


ATHULRAJ
ATHULRAJ 2023년 2월 27일
AF= zeros(2,16);
for m=1:2
for i=1:n(m)
AF=AF+exp((1j)*(((k)*(r(m))*(sin(deg2rad(theta)))*(cos(deg2rad(phi-phi(m,i))))+ ((l(m))*((-k)*r(m)*cos(deg2rad(phio-phi(m,i))))))));
end
end
AFK=AF

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by