wmline using multiple colors
이전 댓글 표시
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
답변 (1개)
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)]; 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,:))
카테고리
도움말 센터 및 File Exchange에서 Elementary Polygons에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!