How to plot lines with unordered data points?
    3 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
I have scanned x-y data for different line tracing. When I plot the points as a scatter, it gives a good presentation of the data, as shown in  the figure below.

However, I want to separate out the data as different lines. Currently, the points are randomly aligned and the line plot shows a sketchy presentation (as shown in the figure below).

currently, the data are attached as 'xydata.mat' and excel sheet. I cannot find a way out that I can plot the data as three distinct lines. I want to As my data set contains more of these lines (some inclined), separating them out manually will be too much time consuming. Any ideas will be much appreciated.
0 Commenti
Risposta accettata
  Star Strider
      
      
 il 27 Ott 2022
        One approach — 
LD = load(websave('xydata','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1171138/xydata.mat'));
T = LD.T;
TS = sortrows(T,1);
idx = [find([diff(TS.x)] > 100); size(T,1)];
s = diff([0; idx]);
C = mat2cell(table2array(TS), s, 2);
figure
hold on
for k = 1:numel(C)
    plot(C{k}(:,1), C{k}(:,2))
end
hold off
xlabel('x')
ylabel('y')
.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Scatter Plots in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


