Info

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

could anyone help me to fix the following issue

1 回表示 (過去 30 日間)
Prabha Kumaresan
Prabha Kumaresan 2018 年 1 月 7 日
閉鎖済み: Stephen23 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 件のコメント
Prabha Kumaresan
Prabha Kumaresan 2018 年 1 月 7 日
Sorry. but the error in the code has not be overcomed which keeps me to ask again
Stephen23
Stephen23 2018 年 1 月 7 日
duplicate

回答 (1 件)

Tamir Suliman
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