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

1. ## 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.

Quzah.

3. You are rude

5. 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.

6. 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.

"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."

7. 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.

8. 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.

9. >> 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.

10. >> Perhaps i worded it wrong

you might read this to begin with.

11. I'll do it for \$10

12. oh my god like that is so sad!

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

14. 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?

15. Originally Posted by eth0
I'll do it for \$9.50
\$9.30 and a block of cheese.
Cheeeeeeeeese.