how can i create a smooth curve through data points
Show older comments
from this code Matlab, how can I create a smooth curve through data points? As shown in the figure.
clear
clc
x=-0.6745:0.06745:0.6745;
x1=-0.6499:0.06499:0.6499;
x2=-0.5856:0.05856:0.5856;
f=[21.0956 20.4078 19.6966 18.9596 18.1937 17.3952 16.5596 15.6810 14.7522 13.7634 12.7012 11.5462 10.2690 8.8199 7.1021 4.8672 0.0048 4.8672 7.1021 8.8199 10.2690 ];
f1=[20.7378 20.0626 19.3646 18.6411 17.8892 17.1054 16.2850 15.4225 14.5107 13.5400 12.5972 11.3633 10.1093 8.6865 6.9997 4.8045 0.01215 4.8045 6.9997 8.6865 10.1093];
f2=[19.7669 19.1259 18.4632 17.7764 17.0626 16.3185 15.5396 14.7208 13.8552 12.9336 11.9435 10.8669 9.6763 8.3251 6.7231 4.6374 0.0090 4.6374 6.7231 8.3251 9.6763];
figure
h=plot(x,f,'-o',x1,f1,'-o',x2,f2,'k-o');
set(h(1),'Color',[0.6350 0.0780 0.1840]);
set(h(2),'Color',[0.4660 0.6740 0.1880]);
title('(a)');
hXL=xlabel('V(Volt)','FontSize',11,'FontWeight','bold');
hXL1=ylabel('{\omega(Ghz)}','FontSize',11,'FontWeight','bold','Rotation',0);
hXL1.Position=hXL.Position+[-0.7 12 0];
lgd1 = legend('{\itb_w} {\mu=0}','{\itb_w} {\mu=1nm}','{\itb_w} {\mu=2nm}');
lgd1.FontSize=9;
xlim([-0.6 0.6]);
xticks(-0.6:0.2:0.6);
ylim([0 22]);
grid minor
grid on

Accepted Answer
More Answers (1)
Walter Roberson
on 16 Dec 2023
Edited: Walter Roberson
on 16 Dec 2023
x=-0.6745:0.06745:0.6745;
x1=-0.6499:0.06499:0.6499;
x2=-0.5856:0.05856:0.5856;
f=[21.0956 20.4078 19.6966 18.9596 18.1937 17.3952 16.5596 15.6810 14.7522 13.7634 12.7012 11.5462 10.2690 8.8199 7.1021 4.8672 0.0048 4.8672 7.1021 8.8199 10.2690 ];
f1=[20.7378 20.0626 19.3646 18.6411 17.8892 17.1054 16.2850 15.4225 14.5107 13.5400 12.5972 11.3633 10.1093 8.6865 6.9997 4.8045 0.01215 4.8045 6.9997 8.6865 10.1093];
f2=[19.7669 19.1259 18.4632 17.7764 17.0626 16.3185 15.5396 14.7208 13.8552 12.9336 11.9435 10.8669 9.6763 8.3251 6.7231 4.6374 0.0090 4.6374 6.7231 8.3251 9.6763];
ux = union(union(x, x1),x2);
N = 10;
p = polyfit(x, f, N);
p1 = polyfit(x1, f1, N);
p2 = polyfit(x2, f2, N);
h = plot(ux, polyval(p, ux), '-o', ux, polyval(p1, ux), '-o', ux, polyval(p2, ux), 'k-o');
set(h(1),'Color',[0.6350 0.0780 0.1840]);
set(h(2),'Color',[0.4660 0.6740 0.1880]);
title('(a)');
hXL=xlabel('V(Volt)','FontSize',11,'FontWeight','bold');
hXL1=ylabel('{\omega(Ghz)}','FontSize',11,'FontWeight','bold','Rotation',0);
hXL1.Position=hXL.Position+[-0.7 12 0];
lgd1 = legend('{\itb_w} {\mu=0}','{\itb_w} {\mu=1nm}','{\itb_w} {\mu=2nm}');
lgd1.FontSize=9;
xlim([-0.6 0.6]);
xticks(-0.6:0.2:0.6);
ylim([0 22]);
grid minor
grid on
Categories
Find more on Vector Fields in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



