Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档
资料存档 资料存档
回复
 
主题工具 显示模式
旧 2019-11-26, 02:00   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
默认 Finding the upper-right "crotches" of a matrix

First, apologies for my description. I don't know the matrix semantics related to this type of operation so I cannot even begin to know how to search for it.



In matlab, I have a matrix A:



   1   1   1   1   1
1 1 1 1 1
0 1 1 1 1
0 0 1 1 1
0 0 0 0 1


That I would like to transform to become something like B:



   1   0   0   0   0
0 0 0 0 0
0 1 0 0 0
0 0 0 1 0
0 0 0 0 1


Where the 1's correspond to row-col locations with 1's in the 5 positions above and to the right AND [there is a single 1 either to the left or below OR both left and below positions are zero].



I can see how this might doable by iterating through each position in A, but this may be slow for very large matrices. I was wondering if there is a filter2 or xcorr2 based approach in matlab that might be faster? I tried both with various kernel matrices on a padded version of A (1-padded above and to the right, 0-padded left and below) but can't come to a definitive answer.





More answer...
poster 当前离线   回复时引用此帖
回复


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 19:18


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.