数学建模--插值和拟合实例

数学建模–插值和拟合实例

原文:http://blog.csdn.net/qq_34861102/article/details/76945362


求导数:

 - dV = gradient(V,t);

较为准确的插值(形成一个平滑的曲线,可以看最后一问):

pp = csape(t0,dV);
fdv = ppval(pp,tt0);
plot(tt0,fdv);

  • 拟合(polyfit和polyval)

    数学建模--插值和拟合实例_第1张图片

    a = [1 -6 5 3];
    x = -5:0.3:5;
    y = polyval(a,x);
    subplot(2,2,1);
    plot(x,y,'-');
    title('原图形');
    L = length(x);
    no = randn(1,L);
    %拟合
    b1 = polyfit(x,y+no,2);
    b2 = polyfit(x,y+no,3);
    b3 = polyfit(x,y+no,4);
    
    y1 = polyval(b1,x);
    y2 = polyval(b2,x);
    y3 = polyval(b3,x);
    
    subplot(2,2,2);
    plot(x,y1,'-');
    title('2图形');
    
    subplot(2,2,3);
    plot(x,y2,'-');
    title('3图形');
    
    subplot(2,2,4);
    plot(x,y3,'-');
    title('4图形');

    数学建模--插值和拟合实例_第2张图片

    数学建模--插值和拟合实例_第3张图片

    x = [1 2 3 4 5 6 7 8];
    y0 = [15.3 20.5 27.4 36.6 49.1 65.6 87.87 117.6];
    y = log(y0);
    b = polyfit(x,y,1);
    a = exp(b(2))
    k = (b(1)
    • 插值

    数学建模--插值和拟合实例_第4张图片

    t = [0 3316 6635 10619 13937 17921 21240 25223 28543 32284 35932 39332 39435 43318 44636 49953 53936 57254 60574 64554 68535 71854 75021 79254 82649 85968 89953 93270];
    h = [3175 3110 3054 2994 2947 2892 2850 2795 2752 2697 -1 -1 3550 3445 3350 3260 3167 3087 3012 2927 2842 2767 2697 -1 -1 3475 3397 3340];
    t0 = t./3600;
    V = pi/4*(57*0.3024).*h*0.3024;
    dV = -gradient(V,t0);
    no1 = find(h == -1);
    no2 = [no1(1) - 1 : no1(2) + 1, no1(3) - 1:no1(4) + 1 ];
    t0(no2) = [];
    dV(no2) = [];
    tt0 = 0:0.05:t0(end);
    pp = csape(t0,dV);
    fdv = ppval(pp,tt0);
    plot(tt0,fdv);

    数学建模--插值和拟合实例_第5张图片

你可能感兴趣的:(数模竞赛)