24小时热门版块排行榜    

查看: 1764  |  回复: 6

zyj8119

木虫 (著名写手)


[交流] 【求助】MATLAB错误

CODE:
function CO2
clc;
x=[10,20,30,40,50,60,70,80,90,100];
y1=[0.011,0.013,0.015,0.022,0.026,0.031,0.031,0.033,0.039,0.045];
y2=[0.011,0.012,0.021,0.024,0.027,0.040,0.042,0.042,0.042,0.049];
y3=[0.012,0.017,0.021,0.032,0.035,0.039,0.040,0.041,0.047,0.053];
y4=[0.011,0.015,0.023,0.027,0.035,0.039,0.042,0.049,0.051,0.055];
plot(x,y1,'gx')
hold on
plot(x,y2,'b*')
hold on
plot(x,y3,'r+')
hold on
plot(x,y4,'mo')
xlabel('total pressure(kpa)');ylabel('adsorption capacity(mmol/g)');
yy1=fit(x',y1','smoothingspline');
yy2=fit(x',y2','smoothingspline');
yy3=fit(x',y3','smoothingspline');
yy4=fit(x',y4','smoothingspline');
plot(x,yy1,'g-');
hold on
plot(x,yy2,'b-')
hold on
plot(x,yy3,'r-')
hold on
plot(x,yy4,'m-')
legend('MCM-41 without APTS','MCM-41 with 15APTS','MCM-41 with 30APTS',...
    'MCM-41 with 45APTS');
hold off
end

为什么此程序运行会出现这个错误:
??? Error using ==> diff
Function 'diff' is not supported for class 'cfit'.

Error in ==> cfit.plot at 65
   if any(diff(xdata)<0)

Error in ==> CO2 at 20
plot(x,yy1,'g-');
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

» 抢金币啦!回帖就可以得到:

查看全部散金贴

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
★ ★ ★
zyj8119(金币+1):谢谢参与
zyj8119(金币+19):谢谢提醒! 2010-12-15 18:25:29
robert2020(金币+2):多谢应助! 2010-12-16 09:19:36
[quote]Originally posted by zyj8119 at 2010-12-15 15:49:32:
CODE:
function CO2
clc;
x=[10,20,30,40,50,60,70,80,90,100];
y1=[0.011,0.013,0.015,0.022,0.026,0.031,0.031,0.033,0.039,0.045];
y2=[0.011,0.012,0.021,0.024,0.027,0.040,0.042,0.042,0.042,0.049];
... [/quote]

[code]
function CO2
clc;
x=[10,20,30,40,50,60,70,80,90,100];
y1=[0.011,0.013,0.015,0.022,0.026,0.031,0.031,0.033,0.039,0.045];
y2=[0.011,0.012,0.021,0.024,0.027,0.040,0.042,0.042,0.042,0.049];
y3=[0.012,0.017,0.021,0.032,0.035,0.039,0.040,0.041,0.047,0.053];
y4=[0.011,0.015,0.023,0.027,0.035,0.039,0.042,0.049,0.051,0.055];
plot(x,y1,'gx')
hold on
plot(x,y2,'b*')
% hold on
plot(x,y3,'r+')
% hold on
plot(x,y4,'mo')
xlabel('total pressure(kpa)');ylabel('adsorption capacity(mmol/g)');
yy1=fit(x',y1','smoothingspline');
yy2=fit(x',y2','smoothingspline');
yy3=fit(x',y3','smoothingspline');
yy4=fit(x',y4','smoothingspline');
% plot(x,yy1,'g-');
% hold on
% plot(x,yy2,'b-')
% hold on
% plot(x,yy3,'r-')
% hold on
% plot(x,yy4,'m-')
plot(yy1,'g-');
plot(yy2,'b-');
plot(yy3,'r-');
plot(yy4,'m-');
legend('MCM-41 without APTS','MCM-41 with 15APTS','MCM-41 with 30APTS',...
    'MCM-41 with 45APTS');
hold off
end

2楼2010-12-15 17:22:16
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zmc

金虫 (正式写手)


★ ★ ★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
robert2020(金币+3):多谢应助! 2010-12-29 09:05:21
fit 函数的返回结果并不是实数,而是cfit object cfun,故作图的时候会出错,应改为:
function CO2
clc;
x=[10,20,30,40,50,60,70,80,90,100];
y1=[0.011,0.013,0.015,0.022,0.026,0.031,0.031,0.033,0.039,0.045];
y2=[0.011,0.012,0.021,0.024,0.027,0.040,0.042,0.042,0.042,0.049];
y3=[0.012,0.017,0.021,0.032,0.035,0.039,0.040,0.041,0.047,0.053];
y4=[0.011,0.015,0.023,0.027,0.035,0.039,0.042,0.049,0.051,0.055];
plot(x,y1,'gx')
hold on
plot(x,y2,'b*')
hold on
plot(x,y3,'r+')
hold on
plot(x,y4,'mo')
xlabel('total pressure(kpa)');ylabel('adsorption capacity(mmol/g)');
yy1=fit(x',y1','smoothingspline');
yy2=fit(x',y2','smoothingspline');
yy3=fit(x',y3','smoothingspline');
yy4=fit(x',y4','smoothingspline');
plot(yy1,'g-');
hold on
plot(yy2,'b-')
hold on
plot(yy3,'r-')
hold on
plot(yy4,'m-')
legend('MCM-41 without APTS','MCM-41 with 15APTS','MCM-41 with 30APTS',...
    'MCM-41 with 45APTS');
hold off
end
3楼2010-12-19 21:31:56
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zyj8119

木虫 (著名写手)


引用回帖:
Originally posted by zmc at 2010-12-19 21:31:56:
fit 函数的返回结果并不是实数,而是cfit object cfun,故作图的时候会出错,应改为:
function CO2
clc;
x=[10,20,30,40,50,60,70,80,90,100];
y1=[0.011,0.013,0.015,0.022,0.026,0.031,0.031,0.033,0.039, ...

谢谢,我想问一下,假如是使用别的拟合方式,是不是只要把smoothspline换成需要的就好?
4楼2010-12-19 21:34:06
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zmc

金虫 (正式写手)


★ ★ ★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
robert2020(金币+3):非常感谢虫友应助!辛苦了! 2010-12-21 13:08:56
引用回帖:
Originally posted by zyj8119 at 2010-12-19 21:34:06:

谢谢,我想问一下,假如是使用别的拟合方式,是不是只要把smoothspline换成需要的就好?

恩 对的,具体的方法可以由cflibhelp得到~  祝你好运
For curves:                                                               
    GROUP           DESCRIPTION                                             
    distribution - distribution models such as Weibull                     
    exponential  - exponential function and sum of two exponential functions
    fourier      - up to eight terms of fourier series                     
    gaussian     - sum of up to eight gaussian models                       
    power        - power function and sum of two power functions            
    rational     - rational equation models, up to 5th degree / 5th degree  
    sin          - sum of up to eight sin functions                        
    spline       - splines                                                  
    interpolant  - interpolating models                                    
    polynomial   - polynomial models up to degree nine                     
                                                                           
For surfaces:                                                              
    GROUP           DESCRIPTION                                             
    interpolant  - interpolating models                                    
    polynomial   - polynomial models up to degree five                     
    lowess       - lowess smoothing models                                 
                                                                           
To list only the model equations for a group, type CFLIBHELP               
followed by the group name.                                                
Example:                                                                  
   cflibhelp polynomial                                                     
                                                                           
All models in the Curve Fitting Library:                                   
                                                                           
  DISTRIBUTION MODELS

        MODELNAME             EQUATION

         weibull               Y = a*b*x^(b-1)*exp(-a*x^b)


  EXPONENTIAL MODELS

        MODELNAME             EQUATION

          exp1                 Y = a*exp(b*x)
          exp2                 Y = a*exp(b*x)+c*exp(d*x)


  FOURIER SERIES

        MODELNAME             EQUATION

        fourier1               Y = a0+a1*cos(x*p)+b1*sin(x*p)
        fourier2               Y = a0+a1*cos(x*p)+b1*sin(x*p)+a2*cos(2*x*p)+b2*sin(2*x*p)
        fourier3               Y = a0+a1*cos(x*p)+b1*sin(x*p)+...+a3*cos(3*x*p)+b3*sin(3*x*p)
         ...
        fourier8               Y = a0+a1*cos(x*p)+b1*sin(x*p)+...+a8*cos(8*x*p)+b8*sin(8*x*p)

      where p = 2*pi/(max(xdata)-min(xdata)).


  GAUSSIAN SUMS (Peak fitting)

        MODELNAME             EQUATION

         gauss1                Y = a1*exp(-((x-b1)/c1)^2)
         gauss2                Y = a1*exp(-((x-b1)/c1)^2)+a2*exp(-((x-b2)/c2)^2)
         gauss3                Y = a1*exp(-((x-b1)/c1)^2)+...+a3*exp(-((x-b3)/c3)^2)
         ...
         gauss8                Y = a1*exp(-((x-b1)/c1)^2)+...+a8*exp(-((x-b8)/c8)^2)


  INTERPOLANT

        INTERPTYPE            DESCRIPTION

    Curves & Surfaces:
        linearinterp           linear interpolation
        nearestinterp          nearest neighbor interpolation
        cubicinterp            cubic spline interpolation

    Curves Only:
        pchipinterp            shape-preserving (pchip) interpolation

    Surfaces Only:
        biharmonicinterp       biharmonic (MATLAB 4 griddata) interpolation


  POLYNOMIAL MODELS

        MODELNAME             EQUATION

    Curves:
          poly1                Y = p1*x+p2
          poly2                Y = p1*x^2+p2*x+p3
          poly3                Y = p1*x^3+p2*x^2+...+p4
          ...
          poly9                Y = p1*x^9+p2*x^8+...+p10

    Surfaces:

     Model names for polynomial surfaces are 'polyij', where i is the degree in x
     and j is the degree in y. The maximum for both i and j is five. The degree of
     the polynomial is the maximum of i and j. The degree of x in each term will be
     less than or equal to i, and the degree of y in each term will be less than or
     equal to j. For example:

          poly21               Z = p00 + p10*x + p01*y + p20*x^2 + p11*x*y
          poly13               Z = p00 + p10*x + p01*y + p11*x*y + p02*y^2 + p12*x*y^2 + p03*y^3
          poly55               Z = p00 + p10*x + p01*y +...+ p14*x*y^4 + p05*y^5


  POWER MODELS

        MODELNAME             EQUATION

         power1                Y = a*x^b
         power2                Y = a*x^b+c


  RATIONAL MODELS

     Rational Models are polynomials over polynomials with the leading coefficient
     of the denominator set to 1. Model names are 'ratij', where i is the degree of the
     numerator and j is the degree of the denominator. The degrees go up to five for
     both the numerator and the denominator. For example:

        MODELNAME             EQUATION

          rat02                Y = (p1)/(x^2+q1*x+q2)
          rat21                Y = (p1*x^2+p2*x+p3)/(x+q1)
          rat55                Y = (p1*x^5+...+p6)/(x^5+...+q5)


  SUM OF SINE FUNCTIONS

        MODELNAME             EQUATION

          sin1                 Y = a1*sin(b1*x+c1)
          sin2                 Y = a1*sin(b1*x+c1)+a2*sin(b2*x+c2)
          sin3                 Y = a1*sin(b1*x+c1)+...+a3*sin(b3*x+c3)
          ...
          sin8                 Y = a1*sin(b1*x+c1)+...+a8*sin(b8*x+c8)


  SPLINES

     Spline models are only supported for curve fitting, not for surface fitting

        SPLINETYPE             DESCRIPTION

        cubicspline             cubic interpolating spline
        smoothingspline         smoothing spline


  LOWESS

     Lowess models are only supported for surface fitting, not for curve fitting

        MODELNAME          DESCRIPTION

        lowess               local linear regression
        loess                local quadratic regression
5楼2010-12-20 20:56:45
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zyj8119

木虫 (著名写手)


引用回帖:
Originally posted by zmc at 2010-12-20 20:56:45:


恩 对的,具体的方法可以由cflibhelp得到~  祝你好运
For curves:                                                               
    GROUP           DESCRIPTION                                   ...

谢谢支持!!!!
6楼2010-12-20 20:59:18
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

longshan0928

新虫 (初入文坛)


good....;/
7楼2010-12-28 11:42:43
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 zyj8119 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 我的国基提前知道中了,可是同事的操作让我实在接受不了,怎么会有这样的人 +9 家与远方 2026-08-10 14/700 2026-08-13 09:41 by 臭臭不臭01
[基金申请] 奇怪,两个人的filecode固定段从头到尾一模一样 +7 布布和一二 2026-08-10 10/500 2026-08-12 09:12 by 布布和一二
[基金申请] 是这周出结果还是下周出结果? +3 yuleib84 2026-08-11 3/150 2026-08-11 21:53 by jnhyjjm
[基金申请] 小木虫上这么多卖论文的,真有人买论文么?感觉没必要啊 +8 Tide man 2026-08-10 9/450 2026-08-11 20:39 by beefly
[基金申请] 有时候,自然基金真的不能太认真 (我的申报经验) +3 majunge000 2026-08-11 4/200 2026-08-11 20:13 by lch2012
[基金申请] 帮忙看看fileCode +7 wwncly 2026-08-10 13/650 2026-08-11 19:36 by 冰心玉壶晴
[基金申请] 为什么网上很多人说本周 12号出结果 +6 瞬息宇宙 2026-08-10 7/350 2026-08-11 19:25 by Tide man
[硕博家园] 读博的好处 +3 lnee 2026-08-11 3/150 2026-08-11 18:10 by 希望我好好的
[基金申请] 基金中了 +15 laoda193707 2026-08-06 15/750 2026-08-11 00:11 by jiafei2190
[基金申请] 静等基金结果 +5 gjjjzhong 2026-08-10 16/800 2026-08-10 17:19 by Tide man
[基金申请] 国自然结果 +4 Vierhys 2026-08-10 8/400 2026-08-10 15:06 by Vierhys
[基金申请] 据悉今年马上要出结果了 +7 瞬息宇宙 2026-08-10 8/400 2026-08-10 12:42 by Vivilian
[基金申请] 这样的filecode谁见过 +11 布布和一二 2026-08-08 22/1100 2026-08-10 11:10 by wmfsnow
[基金申请] 面上项目filecode邪修 +5 西山十月 2026-08-09 7/350 2026-08-10 07:32 by 仁砚薪传
[基金申请] filecode与中标关系的预测 +5 布布和一二 2026-08-07 5/250 2026-08-09 16:15 by 袁向阳007
[基金申请] fileCode有新解读? +10 Tide man 2026-08-08 18/900 2026-08-09 12:55 by 仁砚薪传
[基金申请] 关于filecode,很负责任的告诉大家 +6 爱看书的可乐 2026-08-08 7/350 2026-08-08 22:13 by a_niu
[基金申请] 关于filecode +4 布布和一二 2026-08-07 7/350 2026-08-07 22:55 by zhanghaozhu
[基金申请] 化学口download_prp&amp;fileCode的固定段好像这几天一直没变,有变的大神么? +3 Tide man 2026-08-07 4/200 2026-08-07 22:39 by Tide man
[基金申请] 固定端突然变了,今天 +6 archvillain 2026-08-06 10/500 2026-08-07 16:03 by 医学老男孩
信息提示
请填处理意见