Azzera filtri
Azzera filtri

How to process a matrix

2 visualizzazioni (ultimi 30 giorni)
Sharen H
Sharen H il 16 Ago 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

Risposta accettata

Matt J
Matt J il 16 Ago 2013
Yes, you can loop backward by doing
for i=m:-1:1
etc...

Più risposte (0)

Categorie

Scopri di più su Shifting and Sorting Matrices in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by