Info

此问题已关闭。 请重新打开它进行编辑或回答。

how to change this code to search on column ?

1 次查看(过去 30 天)
A=[ 0 0 1 0 1 0 1 4 1 0
10 10 6 5 1 1 1 5 6 10 ]
a=[ 10 10 7 5 2 1 2 9 7 10 ]
b = [1 1 2 1 2 1 2 2 2 1 ]
this code to row i want to change it for column
N = 10;
m = size(A,1);
% Pre-allocate the F_Complete matrix
F_Complete = zeros(m, N)
for i = 1:m
if a(i)+b(i)-1 == 10
tempVector = [ones(1,A(i,1)) 0 ones(1,A(i,2)) 0 ones(1,A(i,3))];
F_Complete(i,:) = tempVector(1:N);
end
end
to produce this solution
F_complete = [ 1 1 0 0 0 0 0 1 0 1
1 1 0 0 0 0 0 1 0 1
1 1 0 0 0 0 0 1 0 1
1 1 0 0 0 0 0 1 0 1
1 1 0 0 0 0 0 0 0 1
1 1 0 0 0 0 0 1 0 1
1 1 0 0 0 0 0 1 0 1
1 1 0 0 0 0 0 1 0 1
1 1 0 0 0 0 0 1 0 1
1 1 0 0 0 0 0 1 0 1 ]
  2 个评论
Image Analyst
Image Analyst 2016-4-30
Explain in words, what conditions would you like a column of F_complete to have a 1 at a particular row?

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by