years = [1800, 1810, 1820, 1830, 1840, 1850, 1860, 1870, 1880, 1890,1900, 1910, 1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990,2000, 2010, 2020]; population = [5.3, 7.2, 9.6, 12.9, 17.1, 23.2, 31.4, 38.6, 50.2, 62.9,76.0, 92.0, 106.5, 123.2, 131.7, 150.7, 179.3, 204.0,226.5, 251.4, 281.4, 309.3, 329.4]; t = years - 1800; logistic_model = @(params, t) params(1) ./ (1 + (params(1) - params(2)) ./ params(2) .* exp(-params(3) * t)); initial_guess = [400, 5.3, 0.03]; params = lsqcurvefit(logistic_model, initial_guess, t, population); K = params(1); N0 = params(2); r = params(3); t_2030 = 2030 - 1800; population_2030 = logistic_model(params, t_2030); fprintf('2030年預測人口: %.2f 百萬\n', population_2030); fprintf('擬合引數: 承載能力 K = %.2f, 初始人口 N0 = %.2f, 增長率 r = %.4f\n', K, N0, r); figure; plot(years, population, 'bo', 'DisplayName', '實際資料'); hold on; plot(years, logistic_model(params, t), 'r-', 'DisplayName', 'Logistic模型'); xlabel('年份'); ylabel('人口 (百萬)'); title('美國人口資料與Logistic模型擬合'); legend; grid on;