#include
#include
#include
#define N 4 /* data x array size */
#define M 5 /* data y array size */
#define N2 (N+M-1)
int main() {
int i,n1[N],n2[M],n3[N2];
array double c[N2],x[N]={1,2,3,2},y[M]={0,0,-1,-1.5,-2};
class CPlot plot;
string_t labelx="x",
labely="y";
linspace(n1,0,N-1);
linspace(n2,0,M-1);
linspace(n3,0,N2-1);
conv(c,x,y);
printf("x=%6.3f\n",x);
printf("y=%6.3f\n",y);
printf("c=%6.3f\n",c);
plot.Data2D(n1,x);
plot.PlotType(PLOT_PLOTTYPE_IMPULSES, 0);
plot.AxisRange(PLOT_AXIS_X, 0,7,1);
plot.AxisRange(PLOT_AXIS_Y, -12,4,1);
plot.Label(PLOT_AXIS_X,"n");
plot.Label(PLOT_AXIS_Y,"x[n]");
plot.Title("Input sequence");
plot.Plotting();
plot.DeletePlots();
plot.Data2D(n2,y);
plot.PlotType(PLOT_PLOTTYPE_IMPULSES, 0);
plot.AxisRange(PLOT_AXIS_X, 0,7,1);
plot.AxisRange(PLOT_AXIS_Y, -12,4,1);
plot.Label(PLOT_AXIS_X,"n");
plot.Label(PLOT_AXIS_Y,"y[n]");
plot.Title("Unit Pulse Response sequence");
plot.Plotting();
plot.DeletePlots();
plot.Data2D(n3,c);
plot.PlotType(PLOT_PLOTTYPE_IMPULSES, 0);
plot.AxisRange(PLOT_AXIS_X, 0,7,1);
plot.AxisRange(PLOT_AXIS_Y, -12,4,1);
plot.Label(PLOT_AXIS_X,"n");
plot.Label(PLOT_AXIS_Y,"c[n]");
plot.Title("Output Response sequence");
plot.Plotting();
}
x= 1.000 2.000 3.000 2.000
y= 0.000 0.000 -1.000 -1.500 -2.000
c= 0.000 0.000 -3.000 -3.000 0.000 0.000 0.000 0.000