![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/935009/image.jpeg)
How to plot a road along its height.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Muhammad Qaisar Fahim
el 21 de Mzo. de 2022
Comentada: Sam Chak
el 21 de Mzo. de 2022
Actually the data I have has latitude(x) and longitude(y) of a road and also I have height of the road (z). Now I want to construct a plot which has shows height too and that height should be color coded. How can I do that ?
2 comentarios
Sam Chak
el 21 de Mzo. de 2022
Are you trying to plot a top view of the roads and indicate the height of each road?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/935009/image.jpeg)
Respuesta aceptada
KSSV
el 21 de Mzo. de 2022
Read about surf. It also depends on what data you have and how want to show up the plot. More help on sharing the data and showing your expectations.
7 comentarios
KSSV
el 21 de Mzo. de 2022
Your data is huge, you need to restrict the data to a certain limit, plot and then see.
Más respuestas (1)
Sam Chak
el 21 de Mzo. de 2022
I guess you want to show something like this. Because the data is dense, it is not recommended to show the height of every point. But you can definitely adjust how and which particular point/region that you want to show the heights.
plot(A, B)
for t = 1:4379:numel(A)
text(A(t) + 0.0001, B(t) + 0.0001, ['(',num2str(C(t)),')'])
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/935034/image.png)
7 comentarios
Sam Chak
el 21 de Mzo. de 2022
Wait. I think you need to consider the Earth radius (6371 km) in order to project the location of the points on the curved surface in Cartesian coordinates.
And then at each point, you want to show the elevation in the C.mat data using the color gradient. I think the z coordinate in not needed.
x = (6371).*cos(B).*cos(A);
y = (6371).*cos(B).*sin(A);
z = (6371).*sin(B);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/935079/image.png)
Sam Chak
el 21 de Mzo. de 2022
Is the road curved? We need you to confirm.
x = (6371).*cos(B).*cos(A);
y = (6371).*cos(B).*sin(A);
scatter(x, y)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/935084/image.png)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!