MATLAB: I need to smoothen this curve.Need solution with exact code to be written in line.

averagegraphsmooth

x=[5 10 15 20 25];
nrz=[6.32 5.99 8.84 6.23 12.4];
rz=[10.23 8.10 5.00 6.63 7.71];
csrz=[5.77 6.25 8.06 5.50 7.45];
nrz_dpsk=[6.73 6.36 11.33 5.83 9.63];
rz_dpsk=[10.88 7.29 8.78 7.52 8.33];
plot(x,nrz,'-rd',x,rz,'-ks',x,csrz,'-bv',x,nrz_dpsk,'-g^',x,rz_dpsk,'-mp'),
xlabel('length(km)'),ylabel('Max. Q Factor'),grid;
h=legend('nrz','rz','csrz','nrz_dpsk','rz_dpsk',2);
This much high variation in the values like green format giving Q=6,11.5,6,9.5(APPROX.) at distance of 10,15,20 and 25 kms.I need to average this graph or smooth it so that it may not show this kind of high variations by using a matlab function.

Best Answer

x=[5 10 15 20 25];
nrz=[6.32 5.99 8.84 6.23 12.4];
rz=[10.23 8.10 5.00 6.63 7.71];
csrz=[5.77 6.25 8.06 5.50 7.45];
nrz_dpsk=[6.73 6.36 11.33 5.83 9.63];
rz_dpsk=[10.88 7.29 8.78 7.52 8.33];
xi=5:0.1:25;
nrzi=interp1(x,nrz,xi,'spline');
rzi=interp1(x,rz,xi,'spline');
csrzi=interp1(x,csrz,xi,'spline');
nrzi_dpsk=interp1(x,nrz_dpsk,xi,'spline');
rzi_dpsk=interp1(x,rz_dpsk,xi,'spline');
plot(xi,nrzi,'-rd',xi,rzi,'-ks',xi,csrzi,'-bv',xi,nrzi_dpsk,'-g^',xi,rzi_dpsk,'-mp'),
xlabel('length(km)'),ylabel('Max. Q Factor'),grid;
h=legend('nrz','rz','csrz','nrz_dpsk','rz_dpsk',2);