% data for piecewise affine fitting problem N = 100; K = 4; % kink points i = [... 1;... 26;... 51;... 76;... 101]; % y signal y = [... -4.3256e-01; -1.2656e+00; 9.2533e-01; 1.4877e+00;... 4.5353e-01; 3.1909e+00; 3.5892e+00; 2.7624e+00;... 3.5273e+00; 3.7746e+00; 3.8133e+00; 5.1258e+00;... 4.2117e+00; 7.3832e+00; 5.4636e+00; 6.1139e+00;... 7.4668e+00; 6.8593e+00; 7.1044e+00; 6.7677e+00;... 8.2944e+00; 7.0638e+00; 9.5143e+00; 1.0824e+01;... 8.9082e+00; 1.0858e+01; 1.0854e+01; 7.6063e+00;... 7.3590e+00; 8.9711e+00; 7.6001e+00; 8.2900e+00;... 8.0156e+00; 7.5119e+00; 7.6902e+00; 6.6686e+00;... 6.7908e+00; 3.9975e+00; 4.7802e+00; 4.2433e+00;... 2.3959e+00; 3.8573e+00; 2.1435e+00; 4.2151e+00;... 1.5949e+00; 2.5287e+00; 1.8193e+00; 2.7810e-01;... -1.3707e+00; 3.4081e-01; -5.0532e+00; 3.4723e+00;... 3.3387e+00; 9.6621e+00; 4.5564e+00; -1.2180e+00;... 4.3017e+00; -2.2456e+00; 3.1024e+00; 3.3589e+00;... 4.0002e+00; 2.8107e+00; 1.0275e+01; -4.1700e+00;... 7.7409e+00; 1.0478e+01; 1.0055e+01; 9.6893e+00;... 7.4016e+00; 1.0985e+01; 1.0845e+01; 7.1218e+00;... 6.9127e+00; 7.7206e+00; 2.2243e+00; 9.7660e+00;... 9.7184e+00; 9.5148e+00; 1.0244e+01; 8.0490e+00;... 8.6232e+00; 8.3990e+00; 8.1409e+00; 5.8079e+00;... 6.6120e+00; 6.2379e+00; 4.5922e+00; 4.4580e+00;... 5.8823e+00; 4.2685e+00; 4.3899e+00; 3.6880e+00;... 2.5645e+00; 2.2404e+00; 2.8437e+00; 1.0501e+00;... 2.3812e+00; 1.7690e+00; -2.1714e-02; -2.1714e-02]; % template for plots % y_pwac is the continuous PWA estimate % y_pwa is the PWA estimate % figure(1); % axis([0,100,-10,15]); % hold on; % plot(y,':black'); % plot(y_pwa,'-r'); % plot(y_pwac,'-b'); % display RMS error % disp('RMS error of PWA and PWAC') % [norm(y_pwa-y)/sqrt(N) norm(y_pwac-y)/sqrt(N)]