How to code following equation in MATLAB ?
2 次查看(过去 30 天)
显示 更早的评论
Hello all, I am trying to code the following equation but not getting it correctly.
--- (1)
where , , , f is complex Gaussian random variable (rv) with variance 1 and is also complex Gaussian rv with variance 1. Assume ,
Here basically we have to find for each .
Any help in this regard will be highly appreciated.
3 个评论
回答(1 个)
Divyajyoti Nayak
2023-6-23
Hi Charu,
There are a few issues with both your methods and I also have some doubts about the equation. Is B(m) a function of m and you are assuming B(m) = 1 but want the code to also work for other functions? If so then the lhs of the equation should be c(m,n) not c(n). If B is a constant then it should be just B and not B(m).
In your first method:
You are placing an array inside another array and doing that in a loop.
So after first iteration, cn = [ [], cn1(1)], after second iteration cn = [[ [], cn1(1)], cn1(2)] and so on.
Also in both methods you are not using the index m anywhere inside the loop so the loop is kind of redundant.
In your second method:
Firstly, cn is not an array so you will get only one value at the end (i.e. c(M)).
Secondly, you want N elements in cn but are looping from 1 to M so cn will only be calculated M times not N.
Solution:
I'm giving 2 solutions for getting c(n) and c(m,n).
N = 256;
zeta = 0.5;
M = 10^3;
sn = sqrt(1/2)*(randn(1,N)+1i*randn(1,N)); % This is s(n)
f = sqrt(1/2)*(randn(1,1)+1i*randn(1,1)); % This is f
%If B is a constant
B = 1;
cn = zeta*f*sn*B;
%If B(m) is a function of m
Bm = ones(M,1); %I have taken B(m) = 1, if it is some other function you have to calculate the values
cmn = zeta*f*Bm*sn;
In MATLAB the * operator by default does matrix multiplication so you don't have to loop through elements.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!