wmline using multiple colors

조회 수: 7(최근 30일)
Stephen Blackstock
Stephen Blackstock 2018년 4월 17일
답변: Amy Haskins 2018년 4월 17일
I'd like to use wmline to draw a line connecting lat/lon points using a vector of colors. E.g.:
p = geopoint(lat,lon); hsv(:,1) = altitude/100; hsv(:,2) = 1; hsv(:,3) = 1;
rgb = hsv2rgb(hsv);
wmline(p, 'Color', rgb);
%%%%%%%%%%%%%%%%%%%%%%% In 2018a, I get this error:
Expected Color to be of size 1x3, but it is of size 5568x3.
What's up with this?
Stephen Blackstock


Amy Haskins
Amy Haskins 2018년 4월 17일

For the case of multiple lines with different colors, wmline expects each line to be a separate element of a geoshape vector. The code below would create a geoshape where each lat, lon segment is a separate line.

s = geoshape;
for ii = 1:(length(lat - 1))
  s(ii).Latitude = [lat(ii),lat(ii+1)];
  s(ii).Longitude = [lon(ii),lon(ii+1)];
  s(ii).Altitude = [alt(ii),alt(ii+1)];

As written above, you'll have one too many colors since there is one fewer line segments then there are points. The following line will plot your data using all but the last color.



Community Treasure Hunt

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

Start Hunting!

Translated by