Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

could anyone help me to run the following code without error

1 view (last 30 days)
A=[ 1 2 3 4 5;
11 12 13 14 15;
6 7 8 9 10;
21 22 23 24 25;
26 27 28 29 30];
B=[0 0 41 0 0;
45 0 0 0 0;
0 43 0 0 0;
0 0 0 42 0;
0 0 0 0 44];
a=1:5
for N=2:4
c=randsample(a,N)
B_part=B(c,:)
non_0=sum(B_part)
[~,idx]=find(ismember(a,c))
if N==4
else
a(idx)=[]
end
end
C_after_step_1=cluster_rows(B_part)
calling function
function C=cluster_rows(B_part)
extract the parts of the matrices
A_part=A(rows,:);
B_part=B(rows,:);
non_0=repmat(non_0,length(rows),1);
C=B;
C_part=B_part;
C_part(non_0 & C_part==0)=A_part(non_0 & C_part==0);
C(rows,:)=C_part;
end

Answers (0)

This question is closed.

Tags

Community Treasure Hunt

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

Start Hunting!