-6

I have a file containing 2 columns: time & volts. I'm trying to calculate the frequency of the highest amplitude wave.
(Bear in mind that Each wave is of fixed frequency)

I'm ordering the file in Excel using the volts column in descending order, selecting the top row, then doing the following: 1/time but I get an error as the top row has 0 secs. A divide by zero error!

Where am I going wrong ? Thanks

Time, Volt

0, 0.1842751

1.183778E-08, 0.1842751

2.367556E-08, 0.1842751

3.551333E-08, 0.1842751

.........

1.029887E-06, -0.1842751

1.041724E-06, -0.1842751

1.053562E-06, -0.1842751

1.0654E-06, -0.1842751

1.077238E-06, -0.1842751

1.586262E-06, -0.1842751

  • You honestly expect someone to help you fix something when we not only can't see the code, much less know what language it's written in?! – Jonathon Reinhart Oct 18 '15 at 19:24
  • Before you make a division, test if the denominator is different than 0. Do not divide if the denominator is zero. – Marius Bancila Oct 18 '15 at 19:27
  • 1
    Not to be condescending, but because you are dividing 1/time and time one the first row is zero then 1/0 will get a divide by zero error. If i might ask, what are you trying to do in your 1/time calculation? There may be another way to achieve the required results. Oh yes and post some code, and add a tag for the post for the programming language you're using so that people who know about the language are more likely to see it. :) Have a look at this Stack link on how to ask a good question - and dont take downvotes to heart.. http://stackoverflow.com/help/how-to-ask – David Wilson Oct 18 '15 at 19:27
  • I'm just loading the file in Excel, ordering by the Volts column in descending order, then doing the calculation manually: 1/time to get the frequency of the highest amplitude wave. I just wanted to check if my logic was correct. I thought of not dividing if the denominator is zero, as Marius suggested. I will eventually code it in VB.NET. Thanks – Martin Hunt Oct 18 '15 at 19:59

1 Answers1

0

You should never divide by zero.

  1. locate two consecutive peaks in column B
  2. calculate the time difference between the corresponding times in column A
  3. divide 1 by this time difference

By the way this is not an Excel issue:

enter image description here

Gary's Student
  • 95,722
  • 10
  • 59
  • 99