MATLAB Answers

Info

이 질문은 마감되었습니다.

could anyone help me to fix the following issue

조회 수: 1(최근 30일)
Prabha Kumaresan
Prabha Kumaresan 7 Jan 2018
마감: Stephen Cobeldick 7 Jan 2018
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

John D'Errico
John D'Errico 7 Jan 2018
It seems like you will ask this question a dozen times or more. Please stop asking it over and over again.
Prabha Kumaresan
Prabha Kumaresan 7 Jan 2018
Sorry. but the error in the code has not be overcomed which keeps me to ask again

답변(1개)

Tamir Suliman
Tamir Suliman 7 Jan 2018
I think may be you should check the idx

  댓글 수: 0

이 질문에 답변하려면 로그인을(를) 수행하십시오.

태그


Translated by