Hey Guys, I just got assigned this problem and dont even know to start doing it. Any help is greatly appericated.
The last sample program (above) generates a sine and a cosine waveform (angle, or perhaps time, in column 2, cosine in column 3 and sine in column 4. Write a program to generate 400 (x,y) points of a sawtooth waveform that repeats every 100 points, with a minimum of 0 and a maximum of 5 (as if it were the output of a 0-5v sawtooth wave from a waveform generator). Let x range from 0 to 1.0, and y range from 0 to 5.0. If you plot your output with excel or matlab, you should get something like this:
Write your output to a file called “sawtooth.txt”. The first few lines of your file should look something like the following. (You do not need to worry about making the columns line up, but if you want to, look up setw( ) and setprecision( ) in the textbook or via googling):
Hint: the modulus (%) operator comes in handy here…think about what
i % 100
gives you (assuming you’re using i as a loop counter, from 0-399).
You have an another program that generates points. All you need to do, is to make sure the x ranges as expected, and that instead of cos(x), you compute y from x in some other way. Your homework includes hints.