How To Approximate Data With Model

조회 수: 4 (최근 30일)
econogist
econogist 2022년 5월 6일
답변: Mathieu NOE 2022년 5월 9일
I have a model that spits out TFPmodel as shown in the code below. I want to show how the vector called TFPmodel can approximate actual TFP growth (realgA in code below) from 1950 to 2100. The problem is TFPmodel is a size of 1X31. Is there any way I can get this to approximate the whole period so it looks like the other ("Other.png") attached image?
realdata=readmatrix('RATM.csv');
Year=realdata(:,1);
realgA=realdata(:,2);
TFPmodel=[0 0.01 0.012 0.015 0.02 0.025 0.025 0.025 0.025 0.025 0.026 0.025 0.026 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025];
plot(Year, realgA, 'r--', 'LineWidth', 1.5)
set(gca,'FontName','Times','FontSize',11);
ylabel('TFP growth (g_A)','FontSize',11)
ylim([-0.01 0.05])
yticks([-0.01 0 0.01 0.02 0.03 0.04 0.05])
xlim([1950 2100])
hold on
grid on
box on

채택된 답변

Mathieu NOE
Mathieu NOE 2022년 5월 9일
hello
maybe this ?
clc
clearvars
realdata=readmatrix('RATM.csv');
Year=realdata(:,1);
realgA=realdata(:,2);
TFPmodel=[0 0.01 0.012 0.015 0.02 0.025 0.025 0.025 0.025 0.025 0.026 0.025 0.026 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025];
TFPmodel2 = interp1((0:numel(TFPmodel)-1)./numel(TFPmodel),TFPmodel,(0:numel(Year)-1)./numel(Year));
plot(Year, realgA, 'r--', 'LineWidth', 1.5)
hold on
plot(Year,TFPmodel2)
grid on
set(gca,'FontName','Times','FontSize',11);
ylabel('TFP growth (g_A)','FontSize',11)
ylim([-0.01 0.05])
yticks([-0.01 0 0.01 0.02 0.03 0.04 0.05])
xlim([1950 2100])
box on

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by