Info

この質問は閉じられています。 編集または回答するには再度開いてください。

# could anyone help me to fix the following issue

1 ビュー (過去 30 日間)
Prabha Kumaresan 2018 年 1 月 7 日

A =[1 2 3 4 5 31;
6 7 8 9 10 32;
11 12 13 14 15 33;
21 22 23 24 25 34;
26 27 28 29 30 35]
B =[
0 0 41 0 0 0;
45 0 0 0 0 0;
0 43 0 0 0 49;
0 0 0 42 0 0;
0 0 0 0 44 0]
% A=rand(50,100)
% B=diag(randi([1 10],50,1))
N_G=2 %No of group
R = cell(N_G,1)
sumR = cell(N_G,1)
for d=1:1:N_G
%------------------------------------------
% select No of UE randomly
%------------------------------------------
if d==N_G
sz=length(B(:,1))
e=sz
else
if d==1
e=randi([2 3])% select No of UE randomly
else
sz=length(B(:,1))
sz=ceil(sz/2)
e=randi([1 sz])% select No of UE randomly
end
end
%------------------------------------------
idx=randsample(1:size(B,1),e)
%------------------------------------------
% Getting arry A and B from random index
%------------------------------------------
for i=1:length(idx)
X(i,:) = B(idx(i),:)
Y(i,:) = A(idx(i),:)
Xi(i)=find(X(i,:))
end
X=[X(1:i,:)]
Y=[Y(1:i,:)]
%------------------------------------------
% Replacing
%------------------------------------------
non_0=sum(X)
non_0=repmat(non_0,i,1)
S=X
S(non_0 & X==0)=Y(non_0 & X==0)
G{d}=S
%-----------------------------------------------------
% deleting the first output from the main array
%-----------------------------------------------------
A(idx,:) = []
B(idx,:) = []
end
C=[G{1};G{2}]
If i run the code i am getting In an assignment A(I) = B, the number of elements
in B and I must be the same.
Error in (line 47) Xi(i)=find(X(i,:))
Could anyone help me to overcome this error.
##### 3 件のコメント表示非表示 2 件の古いコメント
Stephen23 2018 年 1 月 7 日
duplicate

### 回答 (1 件)

Tamir Suliman 2018 年 1 月 7 日
I think may be you should check the idx

### Community Treasure Hunt

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

Start Hunting!

Translated by