Borrar filtros
Borrar filtros

Matlab: problem with connecting points

4 visualizaciones (últimos 30 días)
yoni verhaegen
yoni verhaegen el 27 de Mzo. de 2017
Editada: Walter Roberson el 28 de Mzo. de 2017
Hello all,
I have a dataset with points (X,Y coordinates) that represent the shape of a glacier. However, when I plot them with
% Import glacier shape
Glaciershape = readtable('dem_glacierlocation.txt');
figure(1);
S = Glaciershape(:,1);
T = Glaciershape(:,2);
plot(S,T,'-')
It seems that an points connect when they don't need to (see attachment, at the left upper corner of the shape). Is there a way to fix this? I uploaded the dataset as an attachment.
Thanks!
  1 comentario
KSSV
KSSV el 28 de Mzo. de 2017
You need to understand the file format....file has X and Y, below X and Y there two data points separated by comma? And in between some were the values are not given.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 28 de Mzo. de 2017
Editada: Walter Roberson el 28 de Mzo. de 2017
readtable() cannot read that file, as it uses comma as the decimal separator. To read the data you need
Glaciershape = cell2mat( textscan( regexprep( fileread('dem_glacierlocation.txt'), ',', '.'), '%f %f', 'HeaderLines', 1, 'Collectoutput', 1) );
which will give you an N x 2 numeric array.
The problem you are observing with your data is that those unwanted lines are really there in your data. Your input has no indication of "draw or slew" -- that is, no indication of whether each point should be connected to the previous or next point. Your map tries to represent three disconnected coastlines without using any indication of disconnection. It does that by just reaching one point, continuing over to the first point of the first disconnected region, drawing the complete first disconnected region, continuing on to the first point of the second disconnected region, and continuing on.
You need to find the break-points in the data. One of them is near row end-200 and the other is near row end-94 . Best would be if what you had in your file marked them explicitly as breakpoints; without matters get a bit tougher.
Perhaps you could search for the places where the distance between adjacent points was greater than some threshold, and declare that was a discontinuity.

Categorías

Más información sobre Polar Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by