wmline using multiple colors

2 visualizaciones (últimos 30 días)
Stephen Blackstock
Stephen Blackstock el 17 de Abr. de 2018
Respondida: Amy Haskins el 17 de Abr. de 2018
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);
webmap
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

Respuestas (1)

Amy Haskins
Amy Haskins el 17 de Abr. de 2018

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)];
end

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.

 wmline(s,'Color',rgb(1:end-1,:))

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by