matlab - Connecting points within a matrix via lines (hopefully for a road network) -


to aid question provide following image

enter image description here

basically image consists of 3 pcolor plots on top of each other (for purpose of question single red cell important).

the magenta squares ones of interest me. in matrix magenta squares have been plotted, magenta coloured entries have values, , rest nans. centre cell of magenta squares (or part squares) have same value , smallest amongst of other magenta cells.

my question is, there way connect centre cells of magenta squares form kind of interpretation of road or bridge network? wouldn't every magenta square connect every other magenta square ideally, overall task possible (of connecting points within matrix lines)?

thanks, , if you're not quite sure mean please ask more info.

edit: magenta squares randomly generated each script run (as terrain layer) hence why can't plot line against known start , end point

this perhaps handled better existing matlab toolbox. primitiv tools possible.

assuming have coordinates of "centre cells of magenta squares".

% create example points points = [...     40 80; ...     70 85; ...     60 90; ...     45 110; ...     120 10; ...     120 60; ...     125 70; ...     55 120; ...     ]; n = size(points, 1); 

first need index combinations (many ways this)

% unique combinations [pcomb(:,1) pcomb(:,2)] = find(triu(ones(n),1)); 

then plot lines combining points

% plot points plot(points(:,1),points(:,2),'om');  % plot lines between = 1:size(pcomb,1)     line(points(pcomb(i,:),1), points(pcomb(i,:),2)) end 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -