Error occurred converting from sym to double: Error using mupadmex

Dear all
My name is Le Thanh Ha. I wrote a code for the monetary research but when I run it, the problem came out.
Please help me find an adequate way to solve this problem.
This is my code
syms C0 C1 C2
syms Y0 Y1 Y2
syms pi0 pi1 pi2
syms lambda0 lambda1 lambda2
syms No0 No1 No2
syms De0 De1 De2
syms H0 H1 H2
syms R0 R1 R2
syms s0 s1 s2
% The non-linear system of model
f1 = lambda1 - exp(loga1)*exp(logZ1)/(exp(logZ1)*C1 - gamma*Clag1) + beta*gamma*exp(loga2)/(exp(logZ2)*C2-gamma*C1);
f2 = lambda1 - beta*R1*lambda2/(pi2*exp(logZ2));
f3 = 1 - (1-eta)*pstar1^(1-bar_theta) - eta*exp(logbarPi1)^(chi*(1-bar_theta)*(1-miu))*pilag1^(miu*chi*(1-bar_theta))*pi1^(bar_theta-1); % 6L
f4 = pstar1 - bar_theta/(bar_theta-1)*No1/De1; % 7L
f5 = No1 - lambda1*MC1*Y1 - eta*beta*exp(logbarPi1)^(-(1-miu)*chi*bar_theta)*pi1^(-chi*miu*bar_theta)*pi2^(bar_theta-1)*No2; % 8L
f6 = De1 - lambda1*Y1 - eta*beta*exp(logbarPi1)^((1-miu)*chi*(1-bar_theta))*pi1^(chi*miu*(1-bar_theta))*pi2^(bar_theta-2)*De2; % 9L
f7 = s1 - (1-eta)*pstar1^(-bar_theta) - eta*exp(logbarPi1)^(-bar_theta*chi*(1-miu))*pilag1^(-bar_theta*chi*miu)*pi1^(bar_theta)*slag1;
f8 = Y1 - exp(logZ1)*H1/s1;
f9 = R1 - Rss1*(rlag1/Rss0)^rho_R*((pi1/exp(logbarPi1))^rpi*(Y1/Yss1)^ry)^(1-rho_R)*((pi1/exp(logbarPi1)/(pilag1/exp(logbarPi0))))^rdpi*((Y1/Yss1)/(Ylag1/Yss0))^rdy*exp(eR1); % Monetary rule
f10 = g1 - Y1/Ylag1*exp(logZ1); % 12L
f11 = 1- exp(logZ1)/(exp(logZ1)*q1-gamma*qlag1) + beta*gamma*((exp(loga2)/exp(loga1))/(exp(logZ2)*q2-gamma*q1));
f12 = x1 - Y1/q1;
f13 = exp(loga1) - lambda1*MC1;
f14 = MC1 - exp(loga1)/lambda1;
f15 = Rss1 - zss/beta*exp(logbarPi1);
f16 = pstar_ss1 - ( (1 - eta*exp(logbarPi1)^((1-chi)*(bar_theta-1)))/(1-eta) )^(1/(1-bar_theta));
f17 = sss1 - (1-eta)*pstar_ss1^(-bar_theta)/(1 - eta*exp(logbarPi1)^(bar_theta*(1-chi)));
f18 = MCss1 - (bar_theta-1)/bar_theta*(1 - eta*beta*exp(logbarPi1)^(bar_theta*(1-chi)-1))/(1 - eta*beta*exp(logbarPi1)^((bar_theta-1)*(1-chi)-1))*pstar_ss1;
f19 = Yss1 - (zss-beta*gamma)/(zss-gamma)*((bar_theta-1)/bar_theta*(1 - eta*beta*(exp(logbarPi1))^(bar_theta*(1-chi)-1))/(1 - eta*beta*exp(logbarPi1)^((bar_theta-1)*(1-chi)-1)))* pstar_ss1;
f20 = C1 - Y1;
f21 = Clag2 - C1;
f22 = Ylag2 - Y1;
f23 = xlag2 - x1;
f24 = qlag2 - q1;
f25 = rlag2 - R1;
f26 = pilag2 - pi1;
f27 = slag2 - s1;
f28 = eR2;
f29 = loga2 - (1-rho_a)*log(bar_a) - rho_a*loga1; % 2L: The preference shock
f30 = logTheta2 - (1-rho_theta)*log(bar_theta)- rho_theta*logTheta1; % 4L: The cost-push shock
f31 = logZ2 - log(zss); % 5L: The technology shock
f32 = logbarPi2 - (1 - rho_barPi)*log(barPiStar) - rho_barPi*logbarPi1; % The persistence to inflation shock
%======================== create function f
f = [f1;f2;f3;f4;f5;f6;f7;f8;f9;f10;f11;f12;f13;f14;f15;f16;f17;f18;f19;f20;f21;f22;f23;f24;f25;f26;f27;f28;f29;f30;f31;f32];
% define the vector of controls, y, and states, x
x = [Clag1 rlag1 slag1 pilag1 Rss0 MCss0 Yss0 pstar_ss0 sss0 eR1 logTheta1 loga1 logZ1 logbarPi1];
y = [C1 R1 s1 Y1 MC1 lambda1 No1 De1 pstar1 pi1 H1];
xp = [Clag2 rlag2 slag2 pilag2 Rss1 MCss1 Yss1 pstar_ss1 sss1 eR2 logTheta2 loga2 logZ2 logbarPi2];
yp = [C2 R2 s2 Y2 MC2 lambda2 No2 De2 pstar2 pi2 H2];
approx=2;
[fx,fxp,fy,fyp,fypyp,fypy,fypxp,fypx,fyyp,fyy,fyxp,fyx,fxpyp,fxpy,fxpxp,fxpx,fxyp,fxy,fxxp,fxx]=anal_deriv(f,x,y,xp,yp,approx);
The problem is
The following error occurred converting from sym to double:
Error using mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.
Error in num_eval (line 21)
nf(:)= eval(f(:));
Error in ha_calvo_model (line 265)
num_eval;
I greatly appreciate any help.
Thank you

1 Comment

The code you posted does not refer to num_eval, and does not refer to ha_calvo_model . Your code also does not have 265 lines, so ha_cavlo_model must be some other file.

Answers (0)

This question is closed.

Tags

No tags entered yet.

Asked:

on 1 Mar 2016

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!