How to code following equation in MATLAB ?
3 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Divyajyoti Nayak
on 23 Jun 2023
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 Comments
See Also
Categories
Find more on Mathematics and Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!