24小时热门版块排行榜    

查看: 1527  |  回复: 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 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 材料调剂 +3 恒顺自然 2026-03-02 3/150 2026-03-02 18:49 by L135790
[考研] 高分子化学与物理调剂 +6 好好好1233 2026-02-28 15/750 2026-03-02 18:47 by caszguilin
[考研] 284求调剂 +5 天下熯 2026-03-02 5/250 2026-03-02 18:38 by caszguilin
[考研] 282求调剂 +4 2103240126 2026-03-02 6/300 2026-03-02 18:07 by 2103240126
[考研] 一志愿华中科技大学,化学专业344分,求调剂 +3 邢xing1 2026-03-02 3/150 2026-03-02 17:32 by houyaoxu
[考研] 一志愿华南理工大学材料与化工326分,求调剂 +3 wujinrui1 2026-02-28 3/150 2026-03-02 16:36 by chuocheng
[考研] 材料284求调剂,一志愿郑州大学英一数二专硕 +12 想上岸的土拨鼠 2026-02-28 12/600 2026-03-02 16:18 by youmomaoyan
[考研] 化工专硕348,一志愿985求调剂 +6 弗格个 2026-02-28 9/450 2026-03-02 14:09 by liyongv
[考研] 材料与化工328求调剂 +3 。,。,。,。i 2026-03-02 3/150 2026-03-02 13:09 by houyaoxu
[基金申请] 面上模板改不了页边距吧? +6 ieewxg 2026-02-25 7/350 2026-03-02 12:44 by stidwellNK
[考研] 哈工大计算机刘劼团队招生 +4 hit_aiot 2026-03-01 6/300 2026-03-02 11:53 by 一声问好
[考研] 276求调剂 +4 路lyh123 2026-02-28 5/250 2026-03-02 11:20 by yuchj
[考研] 材料学硕318求调剂 +14 February_Feb 2026-03-01 16/800 2026-03-02 11:17 by yuchj
[考研] 264求调剂 +4 巴拉巴拉根556 2026-02-28 4/200 2026-03-02 10:48 by yuchj
[考研] 材料学调剂 +10 提神豆沙包 2026-02-28 12/600 2026-03-02 09:26 by 李老师!
[考研] 材料复试调剂 +4 学材料的点 2026-03-01 5/250 2026-03-02 08:26 by houyaoxu
[基金申请] 成果系统访问量大,请一小时后再尝试。---NSFC啥时候好哦,已经两天这样了 +4 NSFC2026我来了 2026-02-28 4/200 2026-03-01 22:37 by 铁门栓
[考研] 299求调剂 +3 Y墨明棋妙Y 2026-02-28 5/250 2026-03-01 21:01 by tangxiaotian
[论文投稿] Optics letters投稿被拒求助 30+3 luckyry 2026-02-26 4/200 2026-03-01 09:06 by babero
[考研] 304求调剂 +3 52hz~~ 2026-02-28 5/250 2026-03-01 00:00 by 52hz~~
信息提示
请填处理意见