一个x对应两组y的数据在matlab中拟合怎样将曲线显示到一个图形中

t=[79.5589.5599.55109.55119.55129.55139.55149.55159.55169.55179.55189.55199.55209.552... t=[79.55 89.55 99.55 109.55 119.55 129.55 139.55 149.55 159.55 169.55 179.55 189.55 199.55 209.55 219.55 229.55 239.55 249.55 259.55 269.55 279.55 289.55 299.55 309.55 319.55 329.55 339.55 349.55 359.55 369.55 379.55 389.55];
c=[0.53101 0.52179 0.50123 0.47652 0.45231 0.42542 0.40997 0.38728 0.37084 0.35515 0.33933 0.32311 0.31735 0.30787 0.3017 0.2972 0.28969 0.28652 0.28727 0.28915 0.29334 0.29975 0.30972 0.32113 0.33944 0.35925 0.37153 0.39057 0.45678 0.48005 0.47624 0.50166];
d=[0.51879 0.50849 0.48348 0.46559 0.4435 0.4135 0.40336 0.382 0.36632 0.35128 0.33528 0.32028 0.3155 0.30666 0.30121 0.2964 0.29102 0.28939 0.28983 0.2934 0.30028 0.30755 0.31798 0.32893 0.34736 0.36269 0.37796 0.3948 0.4401 0.46196 0.48057 0.50569];
t是自变量,c和d分别是两次测量的数据,要两次数据都和t拟合,而且要两个拟合曲线显示在一起,以形成对比,求程序,或者指导,有追加
展开
mathtech6688
2012-03-26 · TA获得超过779个赞
知道小有建树答主
回答量:307
采纳率:100%
帮助的人:204万
展开全部

(1)通过对原始数据绘图可看出t-c、t-d都基本符合二次曲线,所以就用二次多项式来拟合所给数据;

(2)代码如下,为了看效果,分别画在两幅图中:

t=[79.55 89.55 99.55 109.55 119.55 129.55 139.55 149.55 159.55 169.55 179.55 189.55 199.55 209.55 219.55 229.55 239.55 249.55 259.55 269.55 279.55 289.55 299.55 309.55 319.55 329.55 339.55 349.55 359.55 369.55 379.55 389.55];

c=[0.53101 0.52179 0.50123 0.47652 0.45231 0.42542 0.40997 0.38728 0.37084 0.35515 0.33933 0.32311 0.31735 0.30787 0.3017 0.2972 0.28969 0.28652 0.28727 0.28915 0.29334 0.29975 0.30972 0.32113 0.33944 0.35925 0.37153 0.39057 0.45678 0.48005 0.47624 0.50166];

d=[0.51879 0.50849 0.48348 0.46559 0.4435 0.4135 0.40336 0.382 0.36632 0.35128 0.33528 0.32028 0.3155 0.30666 0.30121 0.2964 0.29102 0.28939 0.28983 0.2934 0.30028 0.30755 0.31798 0.32893 0.34736 0.36269 0.37796 0.3948 0.4401 0.46196 0.48057 0.50569];

p1 = polyfit(t,c,2); %用来拟合t-c的二次多项式,多项式的系数按降幂排列在数组p1中

p2 = polyfit(t,d,2); %用来拟合t-d的二次多项式,多项式的系数按降幂排列在数组p2中

fc = polyval(p1,t); %计算拟合值

fd = polyval(p2,t); %计算拟合值

%plot(t,c,t,fc,t,d,t,fd,'linewidth',2)

subplot(1,2,1)

plot(t,c,t,fc,'linewidth',2)

legend('t-c','t-fc')

subplot(1,2,2)

plot(t,d,t,fd,'linewidth',2)

legend('t-d','t-fd')

图如下:

ruifengcao
推荐于2017-11-25 · TA获得超过9489个赞
知道大有可为答主
回答量:3579
采纳率:33%
帮助的人:2034万
展开全部
t=[79.55 89.55 99.55 109.55 119.55 129.55 139.55 149.55 159.55 169.55 179.55 189.55 199.55 209.55 219.55 229.55 239.55 249.55 259.55 269.55 279.55 289.55 299.55 309.55 319.55 329.55 339.55 349.55 359.55 369.55 379.55 389.55];
c=[0.53101 0.52179 0.50123 0.47652 0.45231 0.42542 0.40997 0.38728 0.37084 0.35515 0.33933 0.32311 0.31735 0.30787 0.3017 0.2972 0.28969 0.28652 0.28727 0.28915 0.29334 0.29975 0.30972 0.32113 0.33944 0.35925 0.37153 0.39057 0.45678 0.48005 0.47624 0.50166];
d=[0.51879 0.50849 0.48348 0.46559 0.4435 0.4135 0.40336 0.382 0.36632 0.35128 0.33528 0.32028 0.3155 0.30666 0.30121 0.2964 0.29102 0.28939 0.28983 0.2934 0.30028 0.30755 0.31798 0.32893 0.34736 0.36269 0.37796 0.3948 0.4401 0.46196 0.48057 0.50569];
p1=polyfit(t,c,2);
p2=polyfit(t,d,2);
plot(t,c,'r',t,polyval(p1,t),'r',t,d,'b',t,polyval(p2,t),'b','linewidth',2)

红色为一组,蓝色为一组

祝你学习愉快!
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式