Effacer les filtres
Effacer les filtres

How to process a matrix

2 vues (au cours des 30 derniers jours)
Sharen H
Sharen H le 16 Août 2013
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

Réponse acceptée

Matt J
Matt J le 16 Août 2013
Yes, you can loop backward by doing
for i=m:-1:1
etc...
  1 commentaire
Sharen H
Sharen H le 16 Août 2013
Thank a lot

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by