Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

could anyone help me to run the following code without error

1 Ansicht (letzte 30 Tage)
Prabha Kumaresan
Prabha Kumaresan am 7 Jan. 2018
Geschlossen: John D'Errico am 7 Jan. 2018
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

Antworten (0)

Diese Frage ist geschlossen.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by