Please answer Part B as soon as possible. Sorry if the text is not clear. Thanks
ID: 3570702 • Letter: P
Question
Please answer Part B as soon as possible. Sorry if the text is not clear. Thanks.
3.) You are working with a group that is testing a new oscilloscope. The software you are working on is using the below struct to store each signal collected by the team members #define MAXPTS 10000 typedef struct Collections starting time expressed as the number of seconds since 1/1970 time between subsequent samples The values of the signal in volts (12 pts) Draw a diagram of a simple real world signal and relate the elements of signal t to it. (20 pts) Write a function that takes a pointer to a signal along and outputs the signal in the following format: (Example below pts=3. Start time is 123456, dt is 0.5, name is Tom Daniels) Sample output: Tam Daniels collected 3 points starting at 123456-5Explanation / Answer
Wasn't sure whether you're using c or c++. I can change it to more c++ style (cout rather than printf) if you would like. Code is also here: http://pastebin.com/ZtM0KCRZ.
/* Signal.c */
#include <stdio.h>
#define MAXPTS 10000
typedef struct {
char *name; /* name of person collecting data */
int pts; /* number of points in the signal */
int starttime; /* collection starting time expressed as the number of seconds since 1/1/1970 */
double dt; /* time between subsequent samples */
double s[MAXPTS]; /* the values of the signal in volts */
} signal_t;
void disp_signal(signal_t *s);
int main(void) {
signal_t test;
test.name = "Tom Daniels";
test.pts = 3;
test.starttime = 123456;
test.dt = 0.5;
test.s[0] = -1.0;
test.s[1] = 0.0;
test.s[2] = 1.0;
disp_signal(&test);
return 0;
}
void disp_signal(signal_t *sig) {
size_t i;
printf("%s collected %i points starting at %i s. ", sig->name, sig->pts, sig->starttime);
for (i = 0; i < sig->pts; ++i) {
printf("%.2f %.3f ", sig->starttime + sig->dt * i, sig->s[i]);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.