线性拟合一条直线(matlab)

clc;
clear ;
close all;

axis on;
x1=[0,5,8,10,12,15,18,20,22,25,28,30,32,35,38,40,42,45,47,50,53,55,57,60,63 ,66,69, 72,75,78,81,84,87,90,93,96,99,102,105,108,111,114,117,120 ];
y1=[0,28,40,28,16,28,38,28,18,28,36,28,20,28,34,28,22,28,32,28,24,28,30,28,  26,28,29,28,27,28,29,28,28,28,28.8,28,27.2,28,28.5,28,27.5,28,28.3,28];

x2=[0,120];
y2=[28,28];
plot(x2,y2,'--');
hold on;
set(gca,'xTick',[0:10:120]);
set(gca,'ytick',[0:28:56]);
values = spcrv([[x1(1) x1 x1(end)];[y1(1) y1 y1(end)]],3);
plot(values(1,:),values(2,:), 'g');
title('实际温度和理想温度对比');
legend('理想值','真实值')
xlabel('s/t');
ylabel('℃/T');

线性拟合一条直线(matlab)_第1张图片

你可能感兴趣的:(matlab)