Message Boards Message Boards

0
|
3256 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

How can I transform these Strings so that I can plot it?

Posted 10 years ago

Hey guys!

I've imported measurement data into Mathematica (8.1) and I want to plot it, so that I can see a curve. I have a huge amount of pairs of numbers looking like this: {10:51:24.708, 1802.78} But Mathematica seems not to be able to read the time format "10:51:24.708".

Does anyone have an idea how I could plot this?

POSTED BY: Nadine Freistadt

Hey guys!

Hey babe, import the file as a list of pairs {{tString, vReal}, ...} then augment each pair using a function like

In[61]:= Clear[freistadtTime]
freistadtTime[s_String] :=  ToExpression[StringSplit[s, ":"]].{3600, 60, 1}

In[63]:= freistadtTime["10:51:24.708"]
Out[63]= 39084.7

making each pair into a triple {t,v} goes into {t, freistadtTime[t],v}.

Now plot from the new list the Rest of each triple, but use the First of each triple to label the graphics.

If the time interval goes over midnight, one has to take that into account. If more hints are needed, please deliver a sample data file.

POSTED BY: Udo Krause
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract