フィルターのクリア

How to process a matrix

2 ビュー (過去 30 日間)
Sharen H
Sharen H 2013 年 8 月 16 日
clc
clear all
BW=[ 0 0 0 0 1 0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0 0 1 0 0 0
1 0 0 0 1 0 0 0 0 1 0 0 0]
[m,n]=size(BW)
x=1;
y=1;
count=0;
edgedet=edge(BW,'log');
for i=1:m
for j=1:n-1
if(edgedet(i,j)~=edgedet(i,j+1))
c(x)= i;
x= x+1;
d(y)=j;
y=y+1;
break;
count=count+1;
end
end
end
plot(c,d)
is it possible to do the search from the other side of the matrix as we do in C programming
for i=m:1
for j=n:2
if(edgedet(i,j)~=edgedet(i,j-1))
c(x)= i;
x= x+1;
d(y)=j;
y=y+1;
break;
count=count+1;
end
end
end

採用された回答

Matt J
Matt J 2013 年 8 月 16 日
Yes, you can loop backward by doing
for i=m:-1:1
etc...
  1 件のコメント
Sharen H
Sharen H 2013 年 8 月 16 日
Thank a lot

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by