I want to do something with matrices
Info
This question is closed. Reopen it to edit or answer.
Show older comments
So as the titles sugggests, I am doing a research in which I will obtain a set of matrices with only zero and one elements, the goal is to mark a certian behavior in each row of the matrices, if any zero lies between two ones in each row, i want this row marked, example the row (1 0 1), but if any zero lies between after or before ones (not between) that is okay, example (0 0 1). Ofcourse I could do this observation with my eye, but the research will contain a huge number of rows, and it is better to have an automated process. I believe MATLAB could do anything simillar but I dont have enough experience, but if it doesn't please suggest other programs.M
Answers (1)
KALYAN ACHARJYA
on 5 Jun 2019
Edited: KALYAN ACHARJYA
on 5 Jun 2019
x=randi([0 1],10,3) %Just random example
idx1=find(x(:,1)==1);
idx2=find(x(:,2)==0);
idx3=find(x(:,3)==1);
result_rows=intersect(intersect(idx1,idx2),idx3)
Example:
x =
0 1 0
1 0 0
0 1 1
0 1 0
1 0 1
1 0 1
0 0 0
0 0 1
0 0 0
0 1 0
Output
result_rows =
5
6
>>
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!