How to make 2-D plot some points with Latitude, Longitude and Third value in Matlab?

4 visualizaciones (últimos 30 días)
Hi All,
I have 3 vectors, v1=Latitude, v2=Longitude and v3=value (like deformation). I want to make a 2-D plot that shows each point with it's coordinate in lat and lon, and shows the third value as a colour for each point.
Could you please let me know what the best way is to do that?
Thanks, Zahra
  4 comentarios
Sivakandan Mani
Sivakandan Mani el 4 de Jun. de 2019
Hi Zahra,
I have similar kind of data, latitude, longitude and total electron content (TEC),
in the form of three arrays, I want to plot in 2D. I am unable to use either countour or pcolor becuase my TEC is only in the form of arry not in matrix.
Could you help me in this regards. I hope you might found answer for your trouble.
Thanks in advance,
Siva
Dinibel Perez
Dinibel Perez el 16 de Sept. de 2019
Hi!! I have a similiar problem... Could you solve it???? To plot TEC values

Iniciar sesión para comentar.

Respuestas (2)

Kuifeng
Kuifeng el 16 de Abr. de 2016
help contour

Alireza Alizadeh
Alireza Alizadeh el 14 de Ag. de 2018
Editada: Alireza Alizadeh el 14 de Ag. de 2018
First of all you need an origin for the locations. I assumed that the first point is located at (X,Y) = (0,0). Then, you need to obtain the distances and bearing angles of all points with respect to the the first point using the following functions:
if true
function bearing = Bearing_Angle(lat1, lon1, lat2, lon2)
% convert decimal degrees to radians
lon1 = deg2rad(lon1);
lat1 = deg2rad(lat1);
lon2 = deg2rad(lon2);
lat2 = deg2rad(lat2);
bearing = atan2(sin(lon2-lon1)*cos(lat2), cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(lon2-lon1));
bearing = rad2deg(bearing);
bearing = mod((bearing + 360),360);
end
end
if true
function meter = haversine(lat1, lon1, lat2, lon2)
% https://andrew.hedges.name/experiments/haversine/
% convert decimal degrees to radians
lon1 = deg2rad(lon1);
lat1 = deg2rad(lat1);
lon2 = deg2rad(lon2);
lat2 = deg2rad(lat2);
dlon = lon2 - lon1;
dlat = lat2 - lat1;
% haversine formula
a = sin(dlat/2)^2 + cos(lat1) * cos(lat2) * sin(dlon/2)^2;
c = 2 * asin(sqrt(a));
km = 6367 * c;
meter = km*1000;
ft = km*3280;
miles = ft/5280;
end
end
Now, you can try the following code to obtain 2D locations and plot the points:
if true
Locations_XY = zeros(N,2);
Locations_XY(1,:)= [0 0];
for n = 2 : N
theta_deg = Bearing_Ang(1,n);
theta = (2*pi*theta_deg)/360;
d = Dist(1,n);
Locations_XY(n,:)= [d*sin(theta) d*cos(theta)];
end
figure
hold on
box on
for n = 1 : N
plot(Locations_XY(n,1),Locations_XY(n,2),'sb','markersize',40,'markerfacecolor','c');
text(Locations_XY(n,1),Locations_XY(n,2), num2str(n),'FontSize',12,'HorizontalAlignment','center');
end
end

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!

Translated by