Filter löschen
Filter löschen

Info

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

how to change this code to search on column ?

1 Ansicht (letzte 30 Tage)
Firas Al-Kharabsheh
Firas Al-Kharabsheh am 30 Apr. 2016
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentare
Image Analyst
Image Analyst am 30 Apr. 2016
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 am 30 Apr. 2016
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

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