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!