generate an x-matrix at every iteration by for loop

1 回表示 (過去 30 日間)
Ali Al raeesi
Ali Al raeesi 2022 年 11 月 2 日
編集済み: Bruno Luong 2022 年 11 月 3 日
assume that my iteration is 2000 i want to generate H-matrix at every iteration, soi have 2000 H-matrices for every solution.by using for loop then i need calculate c at every iteration(random because H is a random matrix). also using use for-loop
iterations=2000; % here i assume the iterations
for i=1: iterations
H=sqrt(0.5)*(randn+1i*randn)*(1/sqrt(2)); % my H
end
for i=1: iterations
cdf(idx) = log2(det((eye(Nr(2)))+((SNR(idx)/Nt(2))*abs(H)*(abs(H'))))); % my C
end
%% modify my code because i think it wronge to generate H-matrix at every iteration then i need calculate c at every iteration
%% my H is not a matrix can you show me how to generate the H as matrix

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2022 年 11 月 2 日
編集済み: KALYAN ACHARJYA 2022 年 11 月 2 日
for idx=1: 2000
H=sqrt(0.5)*(randn+1i*randn)*(1/sqrt(2)); % my H
%cdf=...
end
#If you wish to save all generated H matrix, use cell array {} to save the H matrix. For cdf case, provide us the Nr or other typical data, so that we can try
cdf(idx) = log2(det((eye(Nr(2)))+((SNR(idx)/Nt(2))*abs(H)*(abs(H'))))); % my C
  3 件のコメント
Bruno Luong
Bruno Luong 2022 年 11 月 2 日
編集済み: Bruno Luong 2022 年 11 月 3 日
If you want to generate a random matrix of size (m x n) you should do
randn(m,n)
not
randn
without argument, which returns a scalar.
Ali Al raeesi
Ali Al raeesi 2022 年 11 月 3 日
Nt = [4 4];
Nr = [1 4];
SNR=-10;
iterations=2000;
for i=1: iterations
H[i]=sqrt(0.5)*(randn(1,2)+1i*randn(1,2))*(1/sqrt(2)); % this way my H will be generated as matrix
cdf1(idx) = log2(det((eye(Nr(1)))+((SNR(idx)/Nt(1))*abs(H)*(abs(H'))))); % c
cdf2(idx) = log2(det((eye(Nr(2)))+((SNR(idx)/Nt(2))*abs(H)*(abs(H'))))); % c
end
B = sort(cdf2(idx)); % to sort c
X-axis (Sorted c)
Y-axis(CDF: between 1/5000 to 5000/5000) by using for-loop

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by