I want to implement these equations in MATLAB but how?

The equations are given in the attachment. Assume lambda=1. How to implement the given equations in MATLAB?

2 Comments

Thanks for your response. It is symbol of Kronecker product

Sign in to comment.

 Accepted Answer

fn=@(theta,k) exp((0:k-1).' * (2i*pi*d/lambda*sin(theta)));
A=fn(theta,M);
B=fn(theta,N);
y=reshape( A*B.', [],1);

7 Comments

Thank you dear Matt J for your response. I ran it like this:
clear all
clc
theta=[10 20 30];
M=10;
N=4;
K=3;
lambda=1;
d=0.5;
fn=@(theta,k) exp((2i*pi*d/lambda*sin(theta))*(0:k-1).');
a=fn(theta,M);
b=fn(theta,N);
y=sum(kron(a,b))
But it gives the following error:
Error using *
Inner matrix dimensions must agree.
Error in MattJ>@(theta,k)exp((2i*pi*d/lambda*sin(theta))*(0:k-1).')
Error in MattJ (line 12)
a=fn(theta,M);
Try this instead.
theta=[10 20 30];
M=10;
N=4;
K=3;
lambda=1;
d=0.5;
fn=@(theta,k) exp((0:k-1).' * (2i*pi*d/lambda*sin(theta)));
A=fn(theta,M);
B=fn(theta,N);
y=reshape( A*B.', [],1)
y =
3.0000 + 0.0000i -2.1000 - 0.7579i 0.8893 - 0.1719i -1.2724 + 1.5341i 2.2985 - 1.2640i -1.8220 + 0.0222i 0.2295 - 0.0361i 0.1951 + 1.2483i 0.8243 - 1.4133i -1.1131 - 0.0234i -2.1000 - 0.7579i 0.8893 - 0.1719i -1.2724 + 1.5341i 2.2985 - 1.2640i -1.8220 + 0.0222i 0.2295 - 0.0361i 0.1951 + 1.2483i 0.8243 - 1.4133i -1.1131 - 0.0234i -0.1750 + 0.9540i 0.8893 - 0.1719i -1.2724 + 1.5341i 2.2985 - 1.2640i -1.8220 + 0.0222i 0.2295 - 0.0361i 0.1951 + 1.2483i 0.8243 - 1.4133i -1.1131 - 0.0234i -0.1750 + 0.9540i 1.0742 - 0.2196i -1.2724 + 1.5341i 2.2985 - 1.2640i -1.8220 + 0.0222i 0.2295 - 0.0361i 0.1951 + 1.2483i 0.8243 - 1.4133i -1.1131 - 0.0234i -0.1750 + 0.9540i 1.0742 - 0.2196i -0.1789 - 0.4202i
Thanks for your response. It works now but the size of y must be 40 x 3
40 is due to product of M and N and 3 is due to three values in theta.. But yours give y as 40 x 1.
I don't see how a 40x3 matrix can come out of your equations. The summation is over vector quantities, not matrices.
Thanks for your response but may be the Kronecker product serves this purpose and I don't see any such command here.
No, the Kronecker product of two vectors is a vector, e.g.,
a=[1;2;3];
b=[4;5];
kron(a,b)
ans = 6×1
4 5 8 10 12 15
I made changes to yours as:
theta=[10 20 30];
M=10;
N=4;
K=3;
lambda=1;
d=0.5;
fn=@(theta,k) exp((0:k-1).' * (2i*pi*d/lambda*sin(theta)));
A=fn(theta,0:M-1);
B=fn(theta,0:N-1);
But now it gives A and B as empty matrices

Sign in to comment.

More Answers (0)

Asked:

on 14 Oct 2021

Commented:

on 14 Oct 2021

Community Treasure Hunt

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

Start Hunting!