Ch produced plot /* The source code for generating the above plot */ #include <math.h> #include <chplot.h> #define NUM1 360 #define NUM2 10 int main() { int i; double x0[NUM1], y0[NUM1]; double x1[NUM1], y1[NUM1]; double x2[NUM2], y2[NUM2]; double x3[NUM1], y3[NUM1]; int line_type=0, line_width =5; class CPlot plot; for(i=0; i<NUM1; i++) { x0[i]= 0 + i*360.0/(NUM1-1); // linspace(x0, 0, 360); y0[i] = sin(x0[i]*M_PI/180); // y0 = sin(x0*M_PI/180); x1[i]= 0 + i*90.0/(NUM1-1); // linspace(x1, 0, 90); y1[i] = sin(x1[i]*M_PI/180); // y1 = sin(x1*M_PI/180); x3[i]= 270 + i*90.0/(NUM1-1); // linspace(x3, 270, 360); y3[i] = sin(x3[i]*M_PI/180); // y3 = sin(x3*M_PI/180); } for(i=0; i<NUM2; i++) { x2[i]= 90 + i*90.0/(NUM2-1); // linspace(x2, 90, 180); y2[i] = sin(x2[i]*M_PI/180); // y2 = sin(x2*M_PI/180); } plot.data2DCurve(x0, y0, NUM1); plot.data2DCurve(x1, y1, NUM1); plot.data2DCurve(x2, y2, NUM2); plot.data2DCurve(x3, y3, NUM1); plot.plotType(PLOT_PLOTTYPE_LINES, 0, line_type, line_width); // line for (x,y) line_width = 1; plot.plotType(PLOT_PLOTTYPE_IMPULSES, 1, line_type, line_width); // impulse plot for (x1, y1) plot.plotType(PLOT_PLOTTYPE_IMPULSES, 2, line_type, line_width); // impulse plot for (x2, y2) plot.plotType(PLOT_PLOTTYPE_IMPULSES, 3, line_type, line_width); // impulse plot for (x3, y3) plot.size(.40, 0.45); // change default plot size 640x480 /* output of the plot as a png file, instead of displaying on screen by default */ plot.outputType(PLOT_OUTPUTTYPE_FILE, "png", "impulse.png"); plot.plotting(); // get the plotting job done return 0; }