473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

How to write a function code which can convert data strings to signal wave like Sine?

Suppose we are getting the data strings at recieving end having some values.
Now i need to write a function in C/C++ which can represent the signal waveform of recieved string. Its just like drawing the curve with given values
Mar 9 '10 #1
9 2281
RedSon
5,000 Expert 4TB
what does the string represent? How is the string made up. Give me an example.
Mar 9 '10 #2
Thaks 4 ur support

Actually string will be a kind of numerical value set.
like
12 34 54 2 3 4 2 1 4 56 7 ........

at recieving end, we want to convert the nos into some waveform.
Mar 11 '10 #3
RedSon
5,000 Expert 4TB
what do the numbers represent? The angle? The x,y tuples? If I throw a bag of numbers at you and ask you to make a wave out of it, how are you going to do that if I don't tell you what the number represent?
Mar 11 '10 #4
Dear sir,
It doesn't matter whether the no's will represent a wave or any other graph.
Likewise if i m getting
x: 12 34 5 3 4 3 2 4 2 44
y: 34 44 5 6 8 5 5 7 5 12

then will that form any shape?
still if u are unable to get me, then please let me know so that i will review my querry again.
thanks
Mar 13 '10 #5
newb16
687 512MB
Well, two array of numbers still can be interpreted in diferent ways, but let's suppose that these denote pairs of points {A_i, B_i}
The thing that is not clear to me is "function in C/C++ which can represent the signal waveform". So consider a input set of one pair of x,y = {1,1}
What a function should have as an argument (one floating-point value?) and what should it return for this set for an argument equals, say, 2?
Mar 13 '10 #6
donbock
2,426 Expert 2GB
How do you want to represent the signal waveform?
  • Are you plotting it on the screen?
  • Are you plotting it on the printer?
  • Are you plotting it into an image file?
  • Are you writing a sequence of values to an A/D chip?
  • etc.

Let's take a look at the example input you provided earlier:
12 34 54 2 3 4 2 1 4 56 7 ........
  • Do these values represent the y-values for a succession of implied x-values?
  • What is the interval between the implied x-values?
  • Are you confident that the interval is constant?
Mar 15 '10 #7
RedSon
5,000 Expert 4TB
Dear sir,
It doesn't matter whether the no's will represent a wave or any other graph.
I think you have bigger problems to worry about first before you tackle this one.
Mar 15 '10 #8
jkmyoung
2,057 Expert 2GB
What I would do is:
1. Store the values.
2. Calculate the correlation of x and y.
If you have a correlation of close to -1 or close to 1, you are looking at more of a linear graph than a wave like graph.

If you have a correlation of close to 0, then you can probably proceed further.

3. Try and figure out the approximate period based on the data. This is more mathematical based, so not well suited to this forum but I'll try to help. Basically you're trying to fit the data so that the maximum areas and minimum areas both have occur in alternating periods. The way to convert this largely depends on what types of variance you expect to see in your data. If you know how you're getting your data, you'll be able to adjust your algorithm accordingly.

Will the rough average of your data will be about the center of your wave line, or are you measuring more the high parts of your data?

To be honest, you haven't given us enough information to proceed further (without resorting to needlessly covering every last case), so if you could give us further information on your data we can help more.
Mar 15 '10 #9
RedSon
5,000 Expert 4TB
Likewise if i m getting
x: 12 34 5 3 4 3 2 4 2 44
y: 34 44 5 6 8 5 5 7 5 12

then will that form any shape?
still if u are unable to get me, then please let me know so that i will review my querry again.
thanks
If I plot your (x,y) data pairs assuming that 12,34 and 34,44... etc. are pairs then my best periodic regression fit yields:
Expand|Select|Wrap|Line Numbers
  1. 2.29055 sin(x) + 4.13434 cos(x) + 14.3573
But the stats on it are not very good, its R2 is only 0.045. You probably want your coefficient of determination to be much higher, maybe in the .90s or so. So as you can see, the data you provide must have meaning attached to it, otherwise you will get garbage.

Remember: Garbage in, garbage out.

Click Me
Mar 15 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Xanax | last post by:
Hi all, I need to produce a sine wave and use the WaveOut APi to sound it on my sound card. I also need to compute Fast Fourier Transform to modify the Sine wave. Any ideas on where to start or...
1
by: Ahmed Fat-hi | last post by:
I need function that generates simple tone with frequency 1562.5 HZ to be played on the audio device for duration 1920 microseconds. i can not use the Beep function since it has the following...
5
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file"....
10
by: Owkmann | last post by:
Can someone give me a rough idea how a value is obtained for a trigonometric function like Math.Sin? What is the algorithm? I'm finding that putting a large number in this function ( > 8000 )...
1
by: Tito | last post by:
For an internet telephone application, I need to be able to read and write data to and from /dev/dsp simultaneously. I wrote some code and its not working. Anyone have any working code to do...
8
by: mcenley | last post by:
can any one please help me in creatind a sine wave in C++ please i also need to play it as a .wav file any random sound within sudible frequency will do
5
by: RayD | last post by:
I'm looking for a simple program or method to generate sine waves or square waves at a desired frequency. Thanks for your help Ray
5
by: MandaRonnie | last post by:
I have an assignment im working on for my computer science class (c programming). My program compiles right, but doesn't run like its suppose to. Could someone help me? Here is the assignment: ...
2
by: Bowlderster | last post by:
Hi,all. I produce a function to analysis the test data,which is wave signal, and stored as array a. I want to figure out how many times it upcrosses zero,which means that when a<0,and a>0, it...
10
by: lasmith329 | last post by:
I've never posted a question on any site before, but after racking my head over this hurdle for days, I've caved. I'm working on a program that creates a kml file and exports it to Google Earth. In...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.