if statement for colour coding data
5 次查看(过去 30 天)
显示 更早的评论
Hi,
I have latitude, longitude and depth data.
I am wanting to create a 2D plot of Lat Vs Long and plot the depth shown as a corrosponding colour indiacting its depth. I would like it to plot 2colours:
Green if depth <11.9 km
Red if depth < 19.8 km
I have created an if statement so far but it only shows the red stars
Thnak in advance! Pri
0 个评论
采纳的回答
Adam
2019-2-5
编辑:Adam
2019-2-5
Create a mask:
greenDataIdx = Depth <= 11.9;
plot( Lat( greenDataIdx ), Long( greenDataIdx ), 'g*' )
hold on
...
Then plot your other data similarly. In your example there is no data with depth > 11.9. I was going to ask what happens to data > 19.8, but there isn't any. You can do the red data just the same though anyway, if any exists:
redDataIdx = Depth > 11.9 && Depth <= 19.8
An if statement where the target of the if is a vector is very rarely what you want. It will evaluate to a single scalar for the entire array.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Geographic Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!