Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

i want to extract valid possibilities from matrix. A screenshot of that matrix is attached here.

1 visualización (últimos 30 días)
I have
Meters= 2
Subcarriers=2
Power levels=[0.5,1]
I wanted to find the total possibilities.. (a picture of the matrix is attached which you can see)
Now i want to extract the valid possibilities which are satisfying our constraint..
that is we can't give same subcarrier to both Meters..
from Picture you will see that possibility 3 and possibility 4 are valid.. similarly poss. 7 poss. 8 and so on..
The following code give us the total possibilities which results i have attached in picture..
clc;clear all;close all;
M=2;
S=[1:2];
%r1=1;
v=0;
P=[0,0.5,1];
pos=(size(S,2)*size(P,2))^M;
m=pos/(size(S,2)*size(P,2));
for i=1:M
r=2*(size(S,2)*size(P,2))^(M-i);
r1=1;
for j=1:(pos/m)
for l=1:(size(S,2)*size(P,2))^i
X(i,r1:r)=S(1,v+1);
r1=r+1;
r=r+2*(size(S,2)*size(P,2))^(M-i);
v=mod(v+1,size(S,2));
end
end
end
for i=1:M
r=(size(S,2)*size(P,2))^(M-i);
r1=1;
for j=1:(pos/m)
for l=1:(size(S,2)*size(P,2))^i
Y(i,r1:r)=P(1,v+1);
r1=r+1;
r=r+(size(S,2)*size(P,2))^(M-i);
v=mod(v+1,size(P,2));
end
end
end
for i=1:M
for j=1:pos
Z(i,(2*j)-1)=X(i,j);
Z(i,2*j)=Y(i,j);
end
end
Z=double(Z)
Thank you

Respuestas (1)

KL
KL el 18 de Oct. de 2017
Try this,
Z_re = arrayfun(@(a) [Z(:,a:a+1)],1:2:size(Z,2),'uni',0);
Z_selected = cell2mat(Z_re(cellfun(@(x) x(1,1)~=x(2,1),Z_re)));

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by