📄 char_2_num.m
字号:
%CHAR_2_NUM: This function converts the latitude and longitude in html page which
% is usually like "latitude, longitude" to numbers(class double) and
% store in separate variables, "latitude","longitude".
%
% Syntax>>
% [latitude,longitude]=char_2_num(a)
%
% Input "a" has class char array and both outputs, latitude and longitude
% are double.
% For example, if a='45.6756, 56.3435', then [p q]=char_2_num(a) results
% in p=45 and q=56 (decimals are neglected).
function [latitude,longitude]=char_2_num(a)
lat=[];
for i=1:length(a)
if a(i)~=','
lat=[lat a(i)];
else,sep=i;
break,end
end
lon=[];
for i=sep+2:length(a)
if a(i)~=' '
lon=[lon a(i)];
else,break,end
end
lat=lat-48;
latt=[];
for i=1:length(lat)
if lat(i)~=-2
latt=[latt lat(i)];
else,break,end
end
lon=lon-48;
long=[];
for i=1:length(lon)
if lon(i)~=-2
long=[long lon(i)];
else,break,end
end
latt=fliplr(latt);
long=fliplr(long);
latitude=0;
for i=1:length(latt)
latitude=latitude+latt(i)*power(10,i-1);
end
longitude=0;
for i=1:length(long)
longitude=longitude+long(i)*power(10,i-1);
end
if latt(length(latt))==-3
latitude=-(latitude+3*power(10,length(latt)-1));
end
if long(length(long))==-3
longitude=-(longitude+3*power(10,length(long)-1));
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -