Determining the intersection of two vectors
69 次查看(过去 30 天)
显示 更早的评论
Below is my working code for a simple program to graph two vectors.
line([0,50],[30,30]); line1 = [0 30 50 30 ];
line([55,55],[15,30]); line2 = [55 15 55 30];
C = intersect(line1,line2)
Below is the visual representation of these two lines:
It is barely visible in the top right corner that these two lines do not intersect. intersect(A,B) however indicates they're intersecting at 30. I assume this is because it treats the vectors as lines which extend forever? Is there any functionality for matlab which would handle only the given space as opposed to infinite length? It should ideally return these lines do not intersect.
Thanks!
0 个评论
采纳的回答
Star Strider
2014-12-19
The intersect function is a set operation in MATLAB. It looks for the points (elements) that ‘line1’ and ‘line2’ have in common. They both have 30 so that is the correct result.
更多回答(3 个)
Azzi Abdelmalek
2014-12-19
line1 and line2 are two arrays,
C = intersect(line1,line2)
will return the common elements to the two arrays
0 个评论
Mouna SAMAALI
2021-5-12
I have a question about how can I convert this Line of code matlab to Simulink . I would like to use only blocks Simulink ?
A=union(A,setxor(B,intersect(B,C)));where A, B et C are vectors
So I ask about blocks Simulink that make the intersection, the union and setxor of two vectors.
Thanks in advance for your help .
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Computer Vision with Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!