密度衰减模拟不起作用

时间:2015-04-28 02:29:57

标签: matlab

我在下面构建了一个估算大气密度的函数。如果运行该程序,则可以看到第二个图(密度图)与数据不匹配。为什么呢?

以下是该计划:

    clc;

    close all;

    clear all;

    heights=[0 1 2 3 4 5 6 7 8 9 10 15 20 25 30 40 50 60 70 80];

    temps=[15 8.5 2 -4.49 -10.98 -17.47 -23.96 -30.45 -36.94 -43.42 -49.90 -56.50 -56.50 -51.60 -46.64 -22.80 -2.50 -26.13 -53.57 -74.51];

    for i = 1:length(temps) %convert the temperatures to kelvin so they are compatible with SI

        temps(i)=temps(i)+273.15;

    end

    scatter(heights,temps)

    xlabel('height (km)')

    ylabel('temperature (K)')

    title('Scatter plot of temperature versus height with polynomial fitted')

    hold on;

    %now make a polynomial from the scatter plot

    polyCoeff=polyfit(heights,temps,5);

    MaxHeight=80;

    heightFinerIntervals = linspace(0,MaxHeight,8000); %1.0 intervals from 1 to 80

    temperaturePolynomialFit = polyval(polyCoeff,heightFinerIntervals);
hold on;
    plot(heightFinerIntervals,temperaturePolynomialFit);

    Patm=101325;
    R=287;
    g=9.8;

    % heightsAtWhichToEstimateDensity=[5 10 20 40 80];

    experimentalDensityAtEachHeight=[.7364 .4135 .0891 .004 1.85*10^-5];

    heightsAtWhichToEstimateDensity=[0 1 2 3 4 5 6 7 8 9 10 15 20 25 30 40 50 60 70 80];

    experimentalDensityAtEachHeight=[1.225 1.112 1.007 .9093 .8194 .7364 .6601 .5900 .5258 .4671 .4135 .1948 8.91*10^-2 4.01*10^-2 1.84*10^-2 4*10^-3 1.03*10^-3 3.1*10^-4 8.28*10^-5 1.85*10^-5];

    estimatedDensityVector=[];

    for m=1:length(heightFinerIntervals)
        heightOfConcern=heightFinerIntervals(m);
        estimatedTemperature=temperaturePolynomialFit(m); %translating the    height to the index of concern.
    frontPartEquation=Patm/(R*estimatedTemperature);

%form another matrix that we’re going to use for trapz…

    integrand=zeros(1,m);

    INTEGRAND_SCALAR_TEST=0;

    % testIntegralValue=0; %for testing purposes, TODO delete

    for q=1:m

        integrand(q)=1/temperaturePolynomialFit(q);

%         INTEGRAND_SCALAR_TEST=INTEGRAND_SCALAR_TEST+1/temperaturePolynomialFit(q);

    end

    integralValue=(g/R)*.01*trapz(integrand);

    if (m==5)   
    disp('INTEGRALvALUE FOR M=5:')
    disp(integralValue)

    end
    if (m==10)   
        disp('INTEGRALvALUE FOR M=10:')
        disp(integralValue)

   end
   if (m==20)   
    disp('INTEGRALvALUE FOR M=20:')
    disp(integralValue)

   end

% integralValue=(g/R)*INTEGRAND_SCALAR_TEST*.01; % test TODO DELETE

   estimatedDensity=frontPartEquation*exp(-integralValue);

    estimatedDensityVector(end+1)=estimatedDensity;

% experimentalDensity=experimentalDensityAtEachHeight(m);

% disp('***********')
% 
% disp('ESIMATED DENSITY:')
% 
% disp(estimatedDensity)
% 
% disp('EXERIMENTAL DENSITY:')
% 
% disp(experimentalDensity)
% 
% disp('***********')

end




    figure;
        scatter(heightsAtWhichToEstimateDensity,experimentalDensityAtEachHeight)
hold on;

   plot(heightFinerIntervals,estimatedDensityVector)

0 个答案:

没有答案