程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了使用 fittype/testCustomModelEvaluation 时出错???索引超出数组边界大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决使用 fittype/testCustomModelEvaluation 时出错???索引超出数组边界?

开发过程中遇到使用 fittype/testCustomModelEvaluation 时出错???索引超出数组边界的问题如何解决?下面主要结合日常开发的经验,给出你关于使用 fittype/testCustomModelEvaluation 时出错???索引超出数组边界的解决方法建议,希望对你解决使用 fittype/testCustomModelEvaluation 时出错???索引超出数组边界有所启发或帮助;

我正在尝试使用 fittype 并拟合代码以使用我定义的函数拟合一些数据。我定义的函数是:

function N = ModeloFrac01(x,Ninf,alf,Alpha)
    n = length(x);
    N0 = 1;
    mu = 1;
    N = zeros(size(x));%zeros(1,n+1);
    N(1) = N0;
    
    for j = 0: n-1
        c0 = coefc(j+1,x,Alpha);
        cj = coefc(j+1,j,Alpha);
        sum = 0;
        for k = 1: j
            ck = coefc(j+1,k,Alpha);
            ck_= coefc(j+1,k-1,Alpha);
            sum = sum + (ck_-ck)/cj*N(k+1);
        end
        N(j+2)=(c0/cj)*N0 - sum + (gamma(2-Alpha)/cj)*alf*mu*N(j+1)*(1-(N(j+1)/Ninf)^(1/mu));
    end
end
function c = coefc(n,mallaT,Alpha)
    Tn = mallaT(n+1);
    Tj1= mallaT(j+2);
    Tj = mallaT(j+1);
    
    if j == n-1
        c = (Tn - Tj)^(-Alpha);
        return;
    end    
    c = ((Tn - Tj)^(1-Alpha) - (Tn - Tj1)^(1-Alpha))/(Tj1 - Tj);
end

现在,我要拟合的函数数据是:

n=500;
x = (0: 225/n: 225)';
y = zeros(1,n+1);
for j = 1: n+1
    if x(j) < 74.238
        y(j) = 1 + 0.0000476062*t(j)^4.7;
    elseif x(j) < 170.946
        y(j) = 2.79939e6 + 12352.1*t(j) - 855123*log(t(j));
    else
        y(j) = -4.93704e6 - 197.125*t(j) + 1.06562e6*log(t(j));
    end            
end

最后,我使用拟合和拟合函数的代码是:

ft = fittype( 'ModeloFrac01(x,Alpha)',...
    'dependent',{'N'},'independent',{'x'},'coefficIEnts',{'Ninf','alf','Alpha'});
f = fit( x,y,ft,'StartPoint',[1.0288e6,0.0171428,1.0] )
semilogy( f,y )

我知道要近似的数据和我定义的近似数据的函数很复杂,但我希望有人能帮助我,因为我得到的错误是:

Error using fittype/testCustomModelEvaluation (line 12)
Expression ModeloFrac01(x,Alpha) is not a valID MATLAB Expression,has non-scalar coefficIEnts,or cannot be evaluated:
Error in fittype Expression ==> ModeloFrac01(x,Alpha)
??? Index exceeds array bounds.

Error in fittype>iCreateFittype (line 371)
    testCustomModelEvaluation( obj );

Error in fittype (line 328)
                obj = iCreateFittype( obj,varargin{:} );

Error in ajusteTest (line 22)
    ft = fittype( 'ModeloFrac01(x,...

Caused by:
    Error using fittype/evaluate (line 102)
    Error in fittype Expression ==> ModeloFrac01(x,Alpha)
    ??? Index exceeds array bounds.

最后,有没有办法定义参数的边界?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

大佬总结

以上是大佬教程为你收集整理的使用 fittype/testCustomModelEvaluation 时出错???索引超出数组边界全部内容,希望文章能够帮你解决使用 fittype/testCustomModelEvaluation 时出错???索引超出数组边界所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: