24小时热门版块排行榜    

查看: 2595  |  回复: 29
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

飞也如铃

新虫 (小有名气)

[求助] 求助大侠帮忙,有关matlab模拟数据

x = [0.768;
0.711;
0.685;
0.671;
0.659;
0.657;
0.655;
0.654;
0.653;
0.654];

y = [4.584;
4.375;
4.234;
4.128;
4.041;
3.972;
3.913;
3.861;
3.815;
3,774];

上面是x,y的数据,公式是
请问哪位大侠帮忙给编辑一下公式代码啊,我自己用matlab模拟不出来,请哪位好心人帮帮忙!
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

飞也如铃(金币+2): 谢谢您的回复,把你的代码放到matlab里能出来上面的结果,但是没有出来非线性拟合图,我想要这个非线性拟合图,请问怎么弄呢? 2011-11-28 16:05:44
我给你写了一个
你的方程是lg应该是10为底对数
matlab里面log表示ln自然对数
CODE:
x = [0.768;
0.711;
0.685;
0.671;
0.659;
0.657;
0.655;
0.654;
0.653;
0.654];

y = [4.584;
4.375;
4.234;
4.128;
4.041;
3.972;
3.913;
3.861;
3.815;
3.774];
opts = fitoptions('Method','Nonlinear','Normalize','On');
opts.StartPoint =  [1 0.1];
ftype = fittype('a+b*log10(1-b*x)+(1-b)*log10(1-b*x+x)','options',opts);
[fresult,gof] = fit(x,y,ftype)

结果
fresult =

     General model:
     fresult(x) = a+b*log10(1-b*x)+(1-b)*log10(1-b*x+x)
       where x is normalized by mean 0.6767 and std 0.03709
     Coefficients (with 95% confidence bounds):
       a =       4.167  (4.126, 4.208)
       b =      0.1139  (0.05999, 0.1677)

gof =

           sse: 0.0207
       rsquare: 0.9665
           dfe: 8
    adjrsquare: 0.9623
          rmse: 0.0509
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
10楼2011-11-23 23:48:58
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

飞也如铃(金币+2): 非常感谢您的回答,终于得到想要的结果了,真的谢谢你。我还想请教你一个问题,就是图上的标注(拟合和原数据这几个字)是怎么添加上去的,横纵坐标上要想放一个表达式,该表达式为Cn,n代表几次方,该怎么弄啊 2011-11-28 20:10:20
CODE:
x = [0.768;
0.711;
0.685;
0.671;
0.659;
0.657;
0.655;
0.654;
0.653;
0.654];
y = [4.584;
4.375;
4.234;
4.128;
4.041;
3.972;
3.913;
3.861;
3.815;
3.774];
opts = fitoptions('Method','Nonlinear','Normalize','On');
opts.StartPoint =  [1 0.1];
ftype = fittype('a+b*log10(1-b*x)+(1-b)*log10(1-b*x+x)','options',opts);
[fresult,gof] = fit(x,y,ftype)
plot(x,fresult(x),'or-')
hold on;
plot(x,y,'*')



The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
11楼2011-11-28 16:55:58
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

legend('拟合','原数据')
xlabel('C^n')
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
12楼2011-11-28 20:15:20
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

xlabel('lg(r/C_m)')
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
14楼2011-11-28 20:31:22
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

plot命令前加一句
box off
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
16楼2011-11-28 21:34:56
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

引用回帖:
23楼: Originally posted by guojunhang at 2011-12-03 17:41:42:
程序运行完毕后
        a =       4.167
        b =      0.1139
我想检验这个拟合效果的时候,使用这样一段程序,
但是执行效果显示,很差,说明这个拟合结果严重不靠谱啊。
期待解释。
其实上面也有 ...

这个x的数据做过归一化处理后再回归的
CODE:
a =  4.167; b = 0.1139;
x = [0.768;
0.711;
0.685;
0.671;
0.659;
0.657;
0.655;
0.654;
0.653;
0.654];
y = [4.584;
4.375;
4.234;
4.128;
4.041;
3.972;
3.913;
3.861;
3.815;
3.774];
figure;
plot(x,y,'k-')
x1=x-mean(x);
x1=x1/std(x1);
hold on;
y_fit = a+b*log10(1-b*x1)+(1-b)*log10(1-b*x1+x1);
plot(x,y_fit,'ro-')

The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
24楼2011-12-03 20:10:35
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

引用回帖:
25楼: Originally posted by guojunhang at 2011-12-03 21:39:31:
我抖胆再问一句:
a = ? ,  b =?

a =  4.167; b = 0.1139;这个程序中不是给了吗,有什么不清楚的吗
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
26楼2011-12-03 21:44:23
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 飞也如铃 的主题更新
信息提示
请填处理意见