Filter löschen
Filter löschen

How to process a matrix

2 Ansichten (letzte 30 Tage)
Sharen H
Sharen H am 16 Aug. 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

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by