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에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
