Info

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

could anyone help me to run the following code without error

1 回表示 (過去 30 日間)
Prabha Kumaresan
Prabha Kumaresan 2018 年 1 月 7 日
閉鎖済み: John D'Errico 2018 年 1 月 7 日
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

回答 (0 件)

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by