Why doesn't this code work ?
2 ビュー (過去 30 日間)
古いコメントを表示
I have this code for plotting circles around GPS stations, it works fine, but when I plot the map and try to plot those stations on the map, it doesn't work. I don't understand why.
clc
clear all; close all;
scriptPath = 'D:\Data\Matlab_scripts\';
GPS_LOC_dir = 'D:\Data\GPS_stations\';
% % This part read the GPS stations information
GPS_station_file =[GPS_LOC_dir 'GPS_Stations.txt'];
delimiter ={'\t',' '};
startRow = 2;
formatSpec = '%s%f%f%[^\n\r]';
fileID = fopen(GPS_station_file,'r');
dataArray2 = textscan(fileID, formatSpec, 'Delimiter', delimiter,'HeaderLines' ,startRow-1, 'MultipleDelimsAsOne', true, 'EmptyValue' ,NaN, 'ReturnOnError', false);
fclose(fileID);
CODE2 = dataArray2{:, 1};
LAT2 = dataArray2{:, 3};
LON2 = dataArray2{:, 2};
% This is the part that draws the Indian map.
whitebg('w');
load coast
m_proj('mercator','long',[68 98],'lat',[0 30]);
axesm('MapProjection','mercator','MapLatLimit',[0 30],'MapLonLimit',[68 98]);
framem
m_coast('patch',[0.7 0.7 0.6]);
m_grid('xtick',12,'ytick',8);
xlabel('Longitude (deg)');
ylabel('Latitude (deg)');
% End of map plot
rad = km2deg(100,'earth');
n = length(LAT2);
r = ones(n,1)*rad;
c = [LON2,LAT2];
plot(LON2,LAT2,'r*');
text(LON2,LAT2, CODE2 ,'fontsize',10,'fontname','times','fontweight','bold');%
hold on
[h,xs,ys] = circles(r,c,'color','g','lineWidth',2);
hold off
it shows only the map, the circles and the stations vanishes.
Without the map codes, I get everything right. But introducing the map, I get only the map.
Can anyone help ? Thanks, Add.
2 件のコメント
Jan
2016 年 3 月 31 日
"Without the map code" - which is the "map code"? Please format your code peroperly using the "{} Code" button.
回答 (2 件)
Walter Roberson
2016 年 4 月 5 日
You should not try to combine plot() and the mapping toolbox on the same axes. The mapping toolbox set up unusual axes properties that plot() does not know about. Instead of plot() you should use plotm()
Chad Greene
2016 年 4 月 5 日
編集済み: Chad Greene
2016 年 4 月 5 日
I suspect you should not call axesm or framem if you're also using m_map functions.
Where'd you get the circles function? If it's mine, check the inputs. My circles function takes inputs in the form circles(x,y,r), but it looks like you're entering circles(r,[x y]).
参考
カテゴリ
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!