# College kid-need help w/ C program by tonight

Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last
• 03-31-2006
kctrk4
College kid-need help w/ C program by tonight
Code:

```#include <stdio.h> #include <math.h> #include "drand.h" #define PI (4*atan(1)) int main(void) {    double A, t, T, p, n, w, y, a, b, c;          A=drand()+1;   T=((drand()+1)*10);   w=(2*PI/T);   p=drand()*2*(4*atan(1));       for(t=0; t<=50; t++)   {  n=(drand()*.6-.3)*A;          y=A*sin( w*t + p) + n;     printf("%f %f \n\n", t, y);     }     return 0; }```
Now modify the program so that while generating the data it uses some method, of your choice, to produce a good estimate of the period from the data. The estimate must be based only on the y values, and could for example use a sliding window.
Then, at the end, generate separate sine data using your sine function with w based on the estimated period, the original values of A and p, and no noise, to plot over the same range of t with points and lines.

It orginally plots just points, now i need to plot a line in addition (along the points as much as possible).Thanks in advance and please keep it real simple if possible.
• 03-31-2006
quzah

Quzah.
• 03-31-2006
kctrk4
You are rude
You don't need to reply or look at my thread
• 03-31-2006
comwiz
• 03-31-2006
kctrk4
It says the entire homework, i already did part1 involving parrallel-series component reliability.
Plus i already have part2 half done which is what i posted.
So thanks for nothing.
• 03-31-2006
comwiz
Well with a title like: "College kid-need help w/ C program by tonight", Thats sure to get people to help you. People get annoyed when people ask others to do homework for them.

If you tried asking:

"I have this much code dont (put code here) but I am having trouble with this next part. I am trying to do whatever but don't understand whatever."
• 03-31-2006
quzah
You didn't do a damn thing. All you did is take the sample code to start the lesson, given to you by your instructor, and posted the entire homework problem, letter for letter. We're not as stupid as you'd like us to be.

Quzah.
• 04-02-2006
kctrk4
Wrong, why are you at these boards. Perhaps i worded it wrong, i needed help finding the period using a sliding window. You couldnt figure it out anyway.

Write a program to produce 51 samples of a noisy sine wave based on the following formula, to be implemented as a C function with at least one argument t (i.e. the other variables can be either arguments or global variables, but the noise n must be added in the main program, not the function):

y = A*sin( w*t + p) + n

for t = 0, 1, 2, ..., 50 where the amplitude A, radian frequency w = 2*pi/T, phase shift p, and additive noise n are randomly generated in the following ranges:
1.0 <= A <= 2.0
10.0 <= T <= 20.0
0.0 <= p <= 2*pi
-0.3*A <= n <= 0.3*A

Note that the random values for A, w, and p are generated just once, whereas random values for the noise n are generated for each sample.
Program output must be double-spaced so it will plot with points and no lines.

Now modify the program so that while generating the data it uses some method, of your choice, to produce a good estimate of the period from the data. The estimate must be based only on the y values, and could for example use a sliding window.

Then, at the end, generate separate sine data using your sine function with w based on the estimated period, the original values of A and p, and no noise, to plot over the same range of t with points and lines.
• 04-02-2006
cboard_member
>> You couldnt figure it out anyway.
If our quzah couldn't figure that out I'd eat my own face.

Seriously, we don't homework here. If you hadn't shoved the question in our faces without posting your attempt (if any) we would have helped you.

You could say sorry now but I doubt it would make any difference judging by the impression you've already made.

:)
• 04-02-2006
Sebastiani
>> Perhaps i worded it wrong

you might read this to begin with.
• 04-02-2006
Brian
I'll do it for \$10
• 04-02-2006
MK4554
oh my god like that is so sad!
• 04-02-2006
eth0
Quote:

Originally Posted by Brian
I'll do it for \$10

I'll do it for \$9.50
• 04-02-2006
Rashakil Fol
Quote:

Originally Posted by kctrk4
Wrong, why are you at these boards. Perhaps i worded it wrong, i needed help finding the period using a sliding window. You couldnt figure it out anyway.

Why can't you do this yourself?
• 04-02-2006
cboard_member
Quote:

Originally Posted by eth0
I'll do it for \$9.50

\$9.30 and a block of cheese.
Cheeeeeeeeese.
Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last