Demo entry 6362956

matlab

   

Submitted by anonymous on May 11, 2017 at 08:55
Language: Matlab. Code size: 825 Bytes.

t=[0 50 100 150 200 250];
e=[0.045 1.228 2.752 4.455 5.810 7.623];

t2=[0:10:300];
e2=[0 0.261 0.525 0.793 1.065 1.34 1.619 1.902 2.189 2.48 2.774 3.072 3.374 3.68 3.989 4.302 4.618 4.937 5.259 5.585 5.913 6.245 6.579 6.916 7.255 7.597 7.941 8.288 8.637 8.988 9.341];

e11=[0.045 1.228 2.752];
e12=[4.455 5.810 7.623];
t11=[0:50:100];
t12=[150:50:250];

e21=[0 0.261 0.525 0.793 1.065 1.34 1.619 1.902 2.189 2.48 2.774 3.072 3.374 3.68 3.989];
e22=[4.302 4.618 4.937 5.259 5.585 5.913 6.245 6.579 6.916 7.255 7.597 7.941 8.288 8.637 8.988 9.341];

p{1}=polyfit(e,t,5);
p{2}=polyfit(e,t,2)
T{1}=polyval(p{1},e21);
T{2}=polyval(p{2},e22);
TO=[T{1} T{2}];
plot(e2,t2);
hold on;
plot(e2,TO);
rmse=sqrt(sum((t2-TO).^2)/length(t2));
title({['分段函数'];['RSME= ' num2str(rmse)]});
legend('原数据','分段拟合结果');
   

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).