# How can I classify data based on two columns??

4 vues (au cours des 30 derniers jours)
Mohammed Alammar le 1 Déc 2019
Réponse apportée : Luna le 2 Déc 2019
hi ,
I have a data as shown below, I need to classify it based on the rho and theta.
I am looking to plot complete line by extract start and end of point for lines . so i need to classfy as follw:
groups : have the same rho and inside it two groups : 1- when theta = -90 which is hirozental line.
2- when theta = 0 which is vertical line.
I have tried that but there somthing wrong which ('Index exceeds the number of array elements (19)')
##### 3 commentairesAfficher 1 commentaire plus ancienMasquer 1 commentaire plus ancien
Mohammed Alammar le 1 Déc 2019
%%
% reconstructedImage_Measurements of lines;
% Number of tiles in the vertical (time) dimension
Nt = 500;
% Number of tiles in the horizontal (frequency) dimension
Nf = 1000;
wz=[1;Nf];
hz=[1;Nt];
for m = 1: length(lines)
if (lines(m).theta==lines(m+1).theta) && (lines(m).rho==lines(m+1).rho)
XY=[lines(m).point1;lines(m+1).point2];
if XY(1,1)==XY(2,1) && (lines(m).theta ==-90)
XY(:,2)= wz;
elseif XY(1,2)==XY(2,2) && (lines(m).theta ==-90)
XY(:,1)= wz;
elseif XY(1,1)==XY(2,1) && (lines(m).theta ==0)
XY(:,2)= hz;
elseif XY(1,2)==XY(2,2) && (lines(m).theta ==0)
XY(:,1)= hz;
end
else
XY=[lines(m).point1;lines(m).point2];
end
plot(XY(:,1),XY(:,2),'LineWidth',2,'Color','red');
end
Luna le 2 Déc 2019
Can you provide the data as a .mat file attached?

Connectez-vous pour commenter.

### Réponses (1)

Luna le 2 Déc 2019
Your error caused from the line for loop. You have 19 elements but m+1 will be 20.
for m = 1:length(lines)-1
...
end
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Get Started with Statistics and Machine Learning Toolbox dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by