24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 1548  |  回复: 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的回帖

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的回帖
查看全部 7 个回答
★ ★ ★
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的回帖
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 352分 化工与材料 +3 海纳百川Ly 2026-03-27 3/150 2026-03-27 17:18 by 杨杨杨紫
[考研] 一志愿南师大0703化学 275求调剂 +4 Ripcord上岸 2026-03-27 4/200 2026-03-27 17:00 by zhyzzh
[考研] 考研化学308分求调剂 +10 你好明天你好 2026-03-23 12/600 2026-03-27 14:43 by shangxh
[考研] 085600,材料与化工321分,求调剂 +9 大馋小子 2026-03-27 9/450 2026-03-27 14:30 by mmm just
[考研] 0856,材料与化工321分求调剂 +4 大馋小子 2026-03-27 4/200 2026-03-27 13:07 by yhmsz
[考研] 303求调剂 +7 安忆灵 2026-03-22 8/400 2026-03-27 11:46 by sanrepian
[考研] 一志愿郑大085600,310分求调剂 +5 李潇可 2026-03-26 5/250 2026-03-27 11:14 by 不吃魚的貓
[考研] 一志愿武汉理工,总分321,英一数二,求老师收留。 +5 nnnnnnn5 2026-03-25 5/250 2026-03-27 04:42 by wxiongid
[考研] 343求调剂 +4 赠我一本书 2026-03-23 4/200 2026-03-27 00:40 by wxiongid
[考研] 336材料求调剂 +7 陈滢莹 2026-03-26 9/450 2026-03-27 00:20 by wxiongid
[考研] 321求调剂 +6 Ymlll 2026-03-24 6/300 2026-03-26 20:50 by 不吃魚的貓
[考研] 085602化学工程求调剂。 +4 平乐乐乐 2026-03-26 4/200 2026-03-26 17:57 by fmesaito
[考研] 一志愿天津大学339材料与化工求调剂 +3 江往卖鱼 2026-03-26 3/150 2026-03-26 09:42 by 王小欠i
[考研] 303求调剂 +6 蓝山月 2026-03-25 6/300 2026-03-25 22:47 by 418490947
[考研] 0854人工智能方向招收调剂 +4 章小鱼567 2026-03-24 4/200 2026-03-25 13:29 by 2177681040
[考研] 一志愿吉林大学材料与化工303分求调剂 +4 为学666 2026-03-24 4/200 2026-03-25 11:27 by BruceLiu320
[有机交流] 有机合成求助 20+3 FENGSHUJEI 2026-03-23 5/250 2026-03-24 19:31 by 88817753
[考研] 305分求调剂(食品工程) +5 Sxy112 2026-03-21 7/350 2026-03-24 12:27 by 544594351
[考研] 材料 271求调剂 +5 展信悦_ 2026-03-21 5/250 2026-03-21 17:29 by 学员8dgXkO
[考研] 材料与化工(0856)304求 B区 调剂 +3 邱gl 2026-03-21 3/150 2026-03-21 13:47 by lature00
信息提示
请填处理意见