24小时热门版块排行榜    

查看: 1539  |  回复: 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 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 0854电子信息求调剂 324 +3 Promise-jyl 2026-03-23 3/150 2026-03-23 13:43 by wangkm
[考研] 求老师收我 +3 zzh16938784 2026-03-23 3/150 2026-03-23 12:56 by ztnimte
[考研] 307求调剂 +3 余意卿 2026-03-21 3/150 2026-03-23 10:32 by Iveryant
[考研] 070300,一志愿北航320求调剂 +3 Jerry0216 2026-03-22 5/250 2026-03-23 09:16 by 。。堂堂
[考研] 293求调剂 +3 涛涛Wjt 2026-03-22 5/250 2026-03-22 22:21 by jiangpengfei
[考研] 一志愿中南化学(0703)总分337求调剂 +9 niko- 2026-03-19 10/500 2026-03-22 16:08 by ColorlessPI
[考博] 招收博士1-2人 +3 QGZDSYS 2026-03-18 4/200 2026-03-22 10:25 by QGZDSYS
[考研] 材料求调剂 +5 @taotao 2026-03-21 5/250 2026-03-21 20:55 by lbsjt
[考研] 0805 316求调剂 +3 大雪深藏 2026-03-18 3/150 2026-03-21 18:55 by 学员8dgXkO
[考研] 【考研调剂】化学专业 281分,一志愿四川大学,诚心求调剂 +11 吃吃吃才有意义 2026-03-19 11/550 2026-03-21 18:23 by 学员8dgXkO
[考研] 材料 271求调剂 +5 展信悦_ 2026-03-21 5/250 2026-03-21 17:29 by 学员8dgXkO
[考研] 299求调剂 +5 shxchem 2026-03-20 7/350 2026-03-21 17:09 by ColorlessPI
[考研] 307求调剂 +3 wyyyqx 2026-03-17 3/150 2026-03-21 03:20 by JourneyLucky
[考研] 二本跨考郑大材料306英一数二 +3 z1z2z3879 2026-03-17 3/150 2026-03-21 02:29 by JourneyLucky
[考研] 一志愿 西北大学 ,070300化学学硕,总分287,双非一本,求调剂。 +3 晨昏线与星海 2026-03-18 3/150 2026-03-21 00:46 by JourneyLucky
[考研] 308求调剂 +3 阿姐阿姐家啊 2026-03-18 3/150 2026-03-20 23:24 by JourneyLucky
[考研] 0856调剂,是学校就去 +8 sllhht 2026-03-19 9/450 2026-03-20 14:25 by 无懈可击111
[考研] 085600材料与化工调剂 324分 +10 llllkkkhh 2026-03-18 12/600 2026-03-19 14:33 by llllkkkhh
[考研] 材料,纺织,生物(0856、0710),化学招生啦 +3 Eember. 2026-03-17 9/450 2026-03-18 10:28 by Eember.
[考研] 一志愿南京大学,080500材料科学与工程,调剂 +4 Jy? 2026-03-16 4/200 2026-03-17 11:02 by gaoqiong
信息提示
请填处理意见