Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
URGENT PLZ..DMS to decimal

Subject: URGENT PLZ..DMS to decimal

From: Abinayan Parthiban

Date: 26 Mar, 2008 19:12:02

Message: 1 of 4


I have Latitude and longitude data in excel in DMS format
with no spaces.. ie DDMMSS or 522401.. And I have loads of
data like that.. I need it to be converted into Decimal
degrees.. Matlab doesnt try to accept my format so I have to
introduce spaces in between the values.. I have no idea how
to convert my format to the format in matlab or in excel to
convert it into decimal degrees..
Can anyone please help me..

Subject: URGENT PLZ..DMS to decimal

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 26 Mar, 2008 19:14:41

Message: 2 of 4

In article <fse762$10q$1@fred.mathworks.com>,
Abinayan Parthiban <abinayanp@yahoo.co.uk> wrote:

>I have Latitude and longitude data in excel in DMS format
>with no spaces.. ie DDMMSS or 522401..

Hint:

>> textscan('522401','%2d%2d%2d')

ans =

    [52] [24] [1]

--
  "You may comand nature to the extent only in which you are willing to
  obey her." -- Walter Russell

Subject: URGENT PLZ..DMS to decimal

From: Yuri Geshelin

Date: 26 Mar, 2008 19:49:02

Message: 3 of 4

"Abinayan Parthiban" <abinayanp@yahoo.co.uk> wrote in
message <fse762$10q$1@fred.mathworks.com>...
>
> I have Latitude and longitude data in excel in DMS format
> with no spaces.. ie DDMMSS or 522401.. And I have loads of
> data like that.. I need it to be converted into Decimal
> degrees.. Matlab doesnt try to accept my format so I have
to
> introduce spaces in between the values.. I have no idea
how
> to convert my format to the format in matlab or in excel
to
> convert it into decimal degrees..
> Can anyone please help me..
>

To parse a text string, you can use either Walter's
suggestion, or replace 'textscan' with 'sscanf'.
But if you want to READ from EXCEL, you will need XLSREAD.

Yuri

Subject: URGENT PLZ..DMS to decimal

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 26 Mar, 2008 19:59:04

Message: 4 of 4

In article <fse9be$739$1@fred.mathworks.com>,
Yuri Geshelin <geshelin@hotmail.com> wrote:

>To parse a text string, you can use either Walter's
>suggestion, or replace 'textscan' with 'sscanf'.

The first argument to textscan() can be a string, which will
be processed instead of processing a file. This case can be
distinguished from the regular case because textscan() otherwise
requires a numeric fid as its first argument (it is textread() that
takes a file name string as its first argument.)

Hence, to parse a text string, one does not need to replace
my use of textscan() with sscanf().
--
  "The quirks and arbitrariness we observe force us to the
  conclusion that ours is not the only universe." -- Walter Kistler

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us