Suppose there are two curves (described by two groups of data): curve 1 and curve 2. The two curves have more than two intersection points. A new curve 3 is obtained by keeping the upper part of the two curves. The problem is that there are several sharp corners at the intersection points on curve 3. How to smooth the curve by rounding off these corners using matlab?
Apply a convolution with a lowpass filter?
n = 4; %// adjust as needed. Higher value gives more smoothing
curve3_smooth = conv(curve3, ones(1,n)/n, 'same');
A better idea, as noted by @Hoki, is to apply the filter twice: once forwards and once backwards, to make the smoothing operation symmetric. You can achieve that with filtfilt
:
n = 2;
curve3_smooth = filtfilt(ones(1,n)/n, 1, curve3);