how to create a matrix in matlab?
古いコメントを表示
L12 L13 L23
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
how to create a matrix
採用された回答
その他の回答 (2 件)
M = dec2bin(0:7)-'0'
[L23, L13, L12] = ndgrid(0:1);
L12 = L12(:); L13 = L13(:); L23 = L23(:);
table(L12, L13, L23)
15 件のコメント
ankanna
2021 年 3 月 16 日
ankanna
2021 年 3 月 16 日
Walter Roberson
2021 年 3 月 16 日
I do not understand your pseudocode.
Are you trying to create an algorithm for link assignment between communicating users?
Walter Roberson
2021 年 3 月 16 日
編集済み: Walter Roberson
2021 年 3 月 16 日
%input is n, scalar integer starting from 0
[
bitget(n,4), bitget(n,3), bitget(n,2);
bitget(n,3), bitget(n,4), bitget(n,1);
bitget(n,2), bitget(n,1), bitget(n,4);
]
Which can be written in terms of
NN = [4, 3, 2; 3 4 1; 2 1 4]
bitget(n,NN)
Why that particular NN? Well, for the case of node = 3, it is
NN = toeplitz(node+1:-1:2);
mask = logical(fliplr(diag(ones(1,node-1),-1)));
NN(mask) = 1;
out = bitget(n, NN)
It is likely that this would have to change for node = 4, but you would need to give more information about the pattern for 4 for me to predict.
node = 3;
NN = toeplitz(node+1:-1:2);
mask = logical(fliplr(diag(ones(1,node-1),-1)));
NN(mask) = 1;
for n = 0:7
out = bitget(n, NN)
end
ankanna
2021 年 3 月 20 日
Walter Roberson
2021 年 3 月 20 日
編集済み: Walter Roberson
2021 年 3 月 20 日
for n = 0:2^nodes-1
out(:,:,n+1)= bitget(n, NN);
end
ankanna
2021 年 3 月 20 日
ankanna
2021 年 3 月 20 日
編集済み: Walter Roberson
2021 年 3 月 24 日
ankanna
2021 年 3 月 20 日
format long g
nodes = 10;
lamda = 0.7;
bits = dec2bin(0:2^nodes-1)-'0';
nl = sum(bits,2);
nu = nodes-nl;
P = lamda.^nl .* (1-lamda).^nu;
P(1:20)
[minP, minidx] = min(P)
bits(minidx,:)
[maxP, maxidx] = max(P)
bits(maxidx,:)
histogram(P)
ankanna
2021 年 4 月 2 日
ankanna
2021 年 4 月 11 日
Walter Roberson
2021 年 4 月 11 日
That code will never do what you want it to do, and it cannot be fixed.
Your source is a paper that is wrong. You need to get corrections from the authors of the paper.
ankanna
2021 年 4 月 20 日
カテゴリ
ヘルプ センター および File Exchange で Memory Usage についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
