필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

how to change this code to search on column ?

조회 수: 1 (최근 30일)
Firas Al-Kharabsheh
Firas Al-Kharabsheh 2016년 4월 30일
마감: MATLAB Answer Bot 2021년 8월 20일
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?
Firas Al-Kharabsheh
Firas Al-Kharabsheh 2016년 4월 30일
this question is like this one http://www.mathworks.com/matlabcentral/answers/281854-how-to-do-this-operation-to-calculate-a-new-matrix , but i want to alter this code to run with a column

답변 (0개)

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by