Not enough input arguments(if isinteger(x))

4 views (last 30 days)
Dear everyone!
I am comparing two models and I get the following error:
Not enough input arguments.
Error in var (line 73)
if isinteger(x)
Error in compa_4 (line 21)
for jj=1:length(var)
My code is:
dynare thesimy.mod;
irf1 = oo_.irfs;
save thesimy.mat irf1;
dynare thesimy2.mod;
irf2 = oo_.irfs;
save thesimy2.mat irf2;
load('thesimy.mat','irf1');
load('thesimy2.mat','irf2');
ending_cell={'_eps_a','_eps_r','_eps_g','_eps_tau'};
%'Hiato do produto', 'Inflação Doméstico', 'Consumo Doméstico',
%'PIB','Inflação IP','Termo de Troca', 'Salário Real', 'Horas de
%Trabalho','Dívida','Câmbio Nominal','Balanço Comercial','Taxa de Juros Real'
for ii=1:length(ending_cell)
HOR=1:options_.irf;
var_titles = {'Hiato do produto', 'Inflação Doméstico', 'Consumo Doméstico', 'PIB', 'Inflação IPC', 'Termo de Troca', 'Salário Real', 'Horas de Trabalho','Dívida', 'Câmbio Nominal','Balanço Comercial','Taxa de Juros Real'};
figure
for jj=1:length(var)
subplot(4,4,jj)
eval(['irf1.' var{1,jj},ending_cell{1,ii}]);
eval(['irf2.' var{1,jj},ending_cell{1,ii}]);
hold on
plot(HOR,[eval(['irf1.' var{1,jj},ending_cell{1,ii}])],'-k',HOR,[eval(['irf2.' var{1,jj},ending_cell{1,ii}])],'–r','LineWidth',2);
title([var_titles{1,jj}] )
end
legend('Modelo com HP', 'Modelo com TC', 'AutoUpdate','off')
end
Thank you for helping to resolve the issue.
  3 Comments
Touré Mohamed
Touré Mohamed on 30 Mar 2021
Thanks you very much,
I tried irf1.([var{1,jj},ending_cell{1,ii}]) but is giving the same problem.
Stephen23
Stephen23 on 30 Mar 2021
Edited: Stephen23 on 30 Mar 2021
"Thanks you very much, I tried ... but is giving the same problem."
My comment above does not fix your problem (nor did I write that it will fix your problem).
My comment above shows you how to write simpler, more efficient code (which is exactly what I wrote):
Rather than this complex and inefficient code:
eval(['irf1.' var{1,jj},ending_cell{1,ii}])
you can easily use this simpler and much more efficient code:
irf1.([var{1,jj},ending_cell{1,ii}])

Sign in to comment.

Accepted Answer

DGM
DGM on 29 Mar 2021
Is var expected to be a variable? If so, then it's not defined. It's helpful to avoid naming variables in a way that overloads existing function names. This is relevant because var() is a function. You're calling var() without any arguments.
help var
Also: formatting your code with the post editor helps make it readable.
  8 Comments
Touré Mohamed
Touré Mohamed on 1 Apr 2021
Edited: Touré Mohamed on 1 Apr 2021
I tried to do what you suggested. But my model is not working.
I received the following error:
Error using copyfile
Cannot write to destination: C:\Users\abdel\Documents. Use the 'f' option to override.
Error in testcom (line 12)
copyfile('S1.mat','S3.mat')
Please take a look at what I did.
dynare thesimyp1.mod;
irf1 = oo_.irfs;
S1 = 'thesimyp1';
save S1.mat S1
dynare thesimyp2.mod;
irf2 = oo_.irfs;
S2 = 'thesimyp2';
save S2.mat S2
copyfile('S1.mat','S3.mat')
S = load('S2.mat');
save('S3.mat','-struct','S','-append')
ending_cell={'_eps_a','_eps_r','_eps_g','_eps_tau'};
%'Hiato do produto', 'Inflação Doméstico', 'Consumo Doméstico',
%'PIB','Inflação IP','Termo de Troca', 'Salário Real', 'Horas de
%Trabalho','Dívida','Câmbio Nominal','Balanço Comercial','Taxa de Juros Real'
for ii=1:length(ending_cell)
HOR=1:options_.irf;
var_titles = {'Hiato do produto', 'Inflação Doméstico', 'Consumo Doméstico', 'PIB', 'Inflação IPC', 'Termo de Troca', 'Salário Real', 'Horas de Trabalho','Dívida', 'Câmbio Nominal','Balanço Comercial','Taxa de Juros Real'};
figure
for jj=1:length(S)
subplot(3,3,jj)
irf1.([S{1,jj},ending_cell{1,ii}]);
irf2.([S{1,jj},ending_cell{1,ii}]);
hold on
plot(HOR,[(['irf1.' S{1,jj},ending_cell{1,ii}])],'-k',HOR,[(['irf2.' S{1,jj},ending_cell{1,ii}])],'--r','LineWidth',2);
title([var_titles{1,jj}])
end
legend('Modelo com HP', 'Modelo com TC', 'AutoUpdate','off')
end
Best regard,
Walter Roberson
Walter Roberson on 2 Apr 2021
I suspect that S3.mat already exists but you cannot write to it. Possibly it is open in another program.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!