Dear All,
I have the following code:
clc
clear all
close all
f=@(x,y)x^2+y;
f=sym(f);
out=subs(f,x,2)
Could you please tell me what should I do to prevent getting an error.
Thanks a lot.
subs sym
c = vpa(a*b,4)
% SYMLOG_NCC
% symbolic log-linearization
% solution in x,c,R,a,f,s,l,pi,m',k',gh'
% reduced system by 1; f=c*F
eqI = str2sym('-x_t+R*a/Ra1*(R_t+a_t)+w*F/Ra1*(w_t+F_t)-w_t+c_t'); % (I)
eqIIL = str2sym('-theta*c_t+alpha*(1-theta)*x_t-R*a/Ra1*(R_t+a_t)-w*F/Ra1*(w_t+F_t)+theta*gh_t'); % LHS of (II)
eqIIR = str2sym('-theta*c_t+alpha*(1-theta)*x_t-R*a/Ra1*(R_t+a_t)-w*F/Ra1*(w_t+F_t)+r1*r_t'); % RHS of (II)
eqIIIL = str2sym('(1-theta)*c_t+(alpha*(1-theta)-1)*x_t-H2_t+theta*gh_t'); % LHS of (III)
eqIIIR = str2sym('(1-theta)*c_t+(alpha*(1-theta)-1)*x_t-H2_t+H21*(H2_t-x/(1-x)*x_t)'); % RHS of (III)
eqIV = str2sym('-a1*a_t+F_t+w_t-R_t'); % (IV)
eqVL = str2sym('c_t+a_t'); % LHS of (V)
eqVR = str2sym('m_t');eqVI = str2sym('-R_t+(pi1*pi_t+r1*r_t)/R1'); % (VI)
eqVII = str2sym('-F_t-1/gamma*a1*a_t-1/gamma*v_t'); % (VII)
eqVIII = str2sym('-f_t+F_t+c_t'); % (VIII)
eqIX = str2sym('-w_t+(1-bet)*(k_t+s_t-l_t)+z_t'); % (IX)
eqX = str2sym('-r_t+(-bet*(s_t-l_t+k_t)+z_t)/r*(r+deltaK)'); % (X)
eqXI = str2sym('-pi1*pi_t+u_t+m_t-gh_t-c_t-a_t'); % LHS of (XI)
eqXIIL = str2sym('y_h*((1-bet)*(k_t+s_t)+bet*l_t+z_t)+(1-deltaK)*k_h*k_t-c_h*c_t-k_h*gh*gh_t'); % LHS of (XII)
eqXIIR = str2sym('k_h*gh*k_t'); % RHS of (XII)
eqXIII = str2sym('H_h*((1-eps)*(k_t-s1*s_t)-eps*(x1*x_t+L1*l_t+f1*f_t))-gh*gh_t'); % LHS of (XIII)
eqXIV = str2sym('-(1+s1)*s_t+x1*x_t+(1+L1)*l_t+f1*f_t'); % (XIV)
eqXV = str2sym('-H2_t+(1-eps)*(k_t-s1*s_t+x1*x_t+L1*l_t+f1*f_t)'); % (XV)
eqI = subs(eqI,{'Ra1','a','w','F','R'},{Ra1,a,w,F,R});eqIIL = subs(eqIIL,{'alpha','theta','Ra1','a','w','F','R'},{alpha,theta,Ra1,a,w,F,R});eqIIR = subs(eqIIR,{'alpha','theta','Ra1','a','w','F','R','r1'},{alpha,theta,Ra1,a,w,F,R,r1});eqIIIL = subs(eqIIIL,{'alpha','theta'},{alpha,theta});eqIIIR = subs(eqIIIR,{'alpha','theta','H21','x'},{alpha,theta,H21,x});eqIV = subs(eqIV,{'a1'},{a1});eqVI = subs(eqVI,{'r1','R1','pi1'},{r1,R1,pi1});eqVII = subs(eqVII,{'gamma','a1'},{gamma,a1});eqIX = subs(eqIX,{'bet'},{bet});eqX = subs(eqX,{'bet','deltaK','r'},{bet,deltaK,r});eqXI = subs(eqXI,{'pi1'},{pi1});eqXIIL = subs(eqXIIL,{'bet','y_h','deltaK','k_h','c_h','gh'},{bet,y_h,deltaK,k_h,c_h,gh});eqXIIR = subs(eqXIIR,{'k_h','gh'},{k_h,gh});eqXIII = subs(eqXIII,{'H_h','eps','s1','x1','L1','f1','gh'},{H_h,eps,s1,x1,L1,f1,gh});eqXIV = subs(eqXIV,{'s1','x1','L1','f1'},{s1,x1,L1,f1});eqXV = subs(eqXV,{'s1','x1','L1','f1','eps'},{s1,x1,L1,f1,eps});w_t = simplify(solve(eqIX,'w_t')); %
F_t = simplify(solve(eqVII,'F_t'));H2_t = simplify(solve(eqXV,'H2_t'));r_t = simplify(solve(eqX,'r_t'));eqVIII = subs(eqVIII,{'F_t'},{F_t});f_t = simplify(solve(eqVIII,'f_t'));H2_t = subs(H2_t,{'f_t'},{f_t});eqXIII = subs(eqXIII,{'f_t'},{f_t});gh_t = simplify(solve(eqXIII,'gh_t'));eqVI = subs(eqVI,{'r_t'},{r_t});R_t = simplify(solve(eqVI,'R_t'));eqVI = subs(eqVI,{'r_t'},{r_t});eqXI = subs(eqXI,{'gh_t'},{gh_t});pi_t = simplify(solve(eqXI,'pi_t'));R_t = subs(R_t,{'pi_t'},{pi_t});eqIV = subs(eqIV,{'F_t','w_t','R_t'},{F_t,w_t,R_t});a_t = simplify(solve(eqIV,'a_t'));%eqV = subs(eqV,{'a_t'},{a_t});
% c_t = simplify(solve(eqV,'c_t'));
% a_t = subs(a_t,{'c_t'},{c_t});
%f_t = subs(f_t,{'a_t','c_t'},{a_t,c_t});
f_t = subs(f_t,{'a_t'},{a_t});eqXIV = subs(eqXIV,{'f_t'},{f_t});s_t = simplify(solve(eqXIV,'s_t'));a_t = subs(a_t,{'s_t'},{s_t});%c_t = subs(c_t,{'s_t'},{s_t});
R_t = subs(R_t,{'s_t','a_t'},{s_t,a_t});w_t = subs(w_t,{'s_t'},{s_t});F_t = subs(F_t,{'a_t'},{a_t});r_t = subs(r_t,{'s_t'},{s_t});eqI = subs(eqI,{'w_t','F_t','R_t','a_t'},{w_t,F_t,R_t,a_t});x_t = simplify(solve(eqI,'x_t'));s_t = subs(s_t,{'x_t'},{x_t});%c_t = subs(c_t,{'x_t'},{x_t});
a_t = subs(a_t,{'x_t'},{x_t});f_t = subs(f_t,{'x_t','s_t'},{x_t,s_t});w_t = subs(w_t,{'x_t'},{x_t});F_t = subs(F_t,{'x_t'},{x_t});H2_t = subs(H2_t,{'s_t','a_t','x_t'},{s_t,a_t,x_t});gh_t = subs(gh_t,{'s_t','f_t','x_t','a_t'},{s_t,f_t,x_t,a_t});R_t = subs(R_t,{'x_t'},{x_t});r_t = subs(r_t,{'x_t'},{x_t});pi_t = subs(pi_t,{'s_t','a_t','x_t'},{s_t,a_t,x_t});% solution in k,m,m1,l,z,u,v
eqIIL = subs(eqIIL,{'x_t','R_t','a_t','w_t','F_t','gh_t'},{x_t,R_t,a_t,w_t,F_t,gh_t});eqIIR = subs(eqIIR,{'x_t','R_t','a_t','w_t','F_t','r_t'},{x_t,R_t,a_t,w_t,F_t,r_t});eqIIIL = subs(eqIIIL,{'x_t','H2_t','gh_t'},{x_t,H2_t,gh_t});eqIIIR = subs(eqIIIR,{'x_t','H2_t'},{x_t,H2_t});eqXIIL = subs(eqXIIL,{'gh_t','s_t','x_t','f_t'},{gh_t,s_t,x_t,f_t});eqVL = subs(eqVL,{'a_t'},{a_t});eqVR = subs(eqVR,{'m_t'},{m_t});
Best Answer