这个拟合的曲线,为什​么第一条好第二条在图​例中是一样.。

14 次查看(过去 30 天)
sepepo
sepepo 2022-11-25
回答: rimomov 2022-11-25
这个拟合的曲线,为什么第一条好第二条在图例中是一样的呢?
d=[500 1000 1500 2000 2500];
t1=[0.299 0.566 0.841 1.117 1.393];
d.^2;
t1.^2;
scatter(d.^2,t1.^2)
hold on
p1=polyfit(d.^2,t1.^2,1);
f1=polyval(p1,d.^2);
plot(d.^2,t1.^2,'r-*')
t2=[0.364 0.517 0.701 0.897 1.099];
t2.^2;
scatter(d.^2,t2.^2)
p2=polyfit(d.^2,t2.^2,1);
f2=polyval(p2,d.^2);
plot(d.^2,f2,'b-s')
t3=[0.592 0.638 0.708 0.799 0.896];
t3.^2;
scatter(d.^2,t3.^2,[0.25 0.25 0.25])
p3=polyfit(d.^2,t3.^2,1);
f3=polyval(p3,d.^2);
plot(d.^2,t3.^2,'g-d')
legend('第一条','第二条','第三条',2)

采纳的回答

rimomov
rimomov 2022-11-25
d=[500 1000 1500 2000 2500];
t1=[0.299 0.566 0.841 1.117 1.393];
d.^2;
t1.^2;
scatter(d.^2,t1.^2,'ro')
hold on
p1=polyfit(d.^2,t1.^2,1);
f1=polyval(p1,d.^2);
plot(d.^2,t1.^2,'r-*')
t2=[0.364 0.517 0.701 0.897 1.099];
t2.^2;
scatter(d.^2,t2.^2,'+')
p2=polyfit(d.^2,t2.^2,1);
f2=polyval(p2,d.^2);
plot(d.^2,f2,'b-s')
t3=[0.592 0.638 0.708 0.799 0.896];
t3.^2;
scatter(d.^2,t3.^2,'gv')
p3=polyfit(d.^2,t3.^2,1);
f3=polyval(p3,d.^2);
plot(d.^2,t3.^2,'g-^')
legend('第一条 (data)','第一条 (fit)','第二条 (data)','第二条 (fit)','第三条 (data)','第三条 (fit)',2)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!