MATLAB: How to make a smooth curve using the following data

interpolationMATLABplotting

x1 = {0,0.0521,0.1042, 0.1563, 0.2083, 0.2604, 0.3125, 0.3646, 0.4167}
y1 = {2.4015, 2.9473, 4.5847, 5.7855, 7.4229, 9.6061, 12.2259, 13.2083, 13.6450}
x2 = {0, 0.0510, 0.1020, 0.1531, 0.2041, 0.2551}
y2 = {1.6836, 2.3150, 3.2620, 3.9986, 4.9456, 6.8397}
plot(x1,y1,x2,y2) _____________This function gives a rough curve.
How do I plot this data in the form of a smooth curve and show all the discrete points?

Best Answer

figure
x1 = [0,0.0521,0.1042, 0.1563, 0.2083, 0.2604, 0.3125, 0.3646, 0.4167];
x1q = linspace(x1(1),x1(end),100);
y1 = [2.4015, 2.9473, 4.5847, 5.7855, 7.4229, 9.6061, 12.2259, 13.2083, 13.6450];
y1q = interp1(x1,y1,x1q,'pchip');
x2 = [0, 0.0510, 0.1020, 0.1531, 0.2041, 0.2551];
x2q = linspace(x2(1),x2(end),100);
y2 = [1.6836, 2.3150, 3.2620, 3.9986, 4.9456, 6.8397];
y2q = interp1(x2,y2,x2q,'pchip');
plot(x1q,y1q,'r',x2q,y2q,'b')
hold on
plot(x1,y1,'ro',x2,y2,'bo')
let me know if this is what you wanted. I suggest reading up interpolation in the documentation.