How can I take the values of one array as inputs to check a condition for another array?
1 view (last 30 days)
Show older comments
Say I have an array like A = [1 1 0; 0 1 0] and B = [1 3; 2 2; 2 3] where B are coordinates in A. How can I input B into A to check if these coordinates = 1? In other words, how can I check if A(1,3), A(2,2), and A(2,3) = 1?
2 Comments
Alexandra Topciov
on 2 Feb 2016
A = [1 1 0; 0 1 0];
B = [1 3; 2 2; 2 3];
for i=1:length(B)
column_1=B(i,1);
column_2=B(i,2);
Answer{i}=A(column_1,column_2)==1;
end
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Scope Variables and Generate Names in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!