how to create a matrix in matlab?
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (2)
M = dec2bin(0:7)-'0'
[L23, L13, L12] = ndgrid(0:1);
L12 = L12(:); L13 = L13(:); L23 = L23(:);
table(L12, L13, L23)
15 Kommentare
ankanna
am 16 Mär. 2021
ankanna
am 16 Mär. 2021
Walter Roberson
am 16 Mär. 2021
I do not understand your pseudocode.
Are you trying to create an algorithm for link assignment between communicating users?
Walter Roberson
am 16 Mär. 2021
Bearbeitet: Walter Roberson
am 16 Mär. 2021
%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
am 20 Mär. 2021
Walter Roberson
am 20 Mär. 2021
Bearbeitet: Walter Roberson
am 20 Mär. 2021
for n = 0:2^nodes-1
out(:,:,n+1)= bitget(n, NN);
end
ankanna
am 20 Mär. 2021
ankanna
am 20 Mär. 2021
Bearbeitet: Walter Roberson
am 24 Mär. 2021
ankanna
am 20 Mär. 2021
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
am 2 Apr. 2021
ankanna
am 11 Apr. 2021
Walter Roberson
am 11 Apr. 2021
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
am 20 Apr. 2021
Kategorien
Mehr zu Memory Usage finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
