Fsolve for different values of a parameter
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello all,
I use fsolve to find the solutions of a system of 5 nonlinear equations. I get the solutions with a value set for each parameter of the model.
However, I would like to calculate the system's solutions for several values of one of the parameter (from 0 to 1 with an increment of 0.01), without having to change it manually each time. I would also like to keep the set of solutions (for each value of the parameter in question), and then make a graph that shows the evolution of each of the variables when the value of the parameter changes.
Is there a simple way to do this?
More precisely:
It is the parameter 'rho' that I want to pass from 0 to 1 with an incrementation of 0.01, then represent the evolution of the variables (theta, eseuil, u ..) according to the value of rho.
Here is my code :
clear all
diary calibration_firmlevel
close all
%%VALUES OF PARAMETERS %%
ebarh=1;
delta=0.3919;
kappa=0.6578;
z=0.2510;
r=0.012;
alpha=0.5;
A=0.7;
gamma=0.2345;
rho=0;
c=0.5;
%%EQUILIBRIUM %%
% Parameters
P=[ebarh,delta,kappa,z,r,alpha,A,gamma,rho,c];
% Initial conditions
theta0=0.72;
eseuil0=0.2;
u0=0.047;
tau0=0.06;
phi0=0;
% Fsolve: find the solutions of non linear system of equations
[X,fval,exitflag,output]=fsolve('equilibrePissarides_expost_firmlevelv4',[theta0,eseuil0,u0,tau0,phi0],optimset('fsolve'),P);
theta=X(1);
eseuil=X(2);
u=X(3);
tau=X(4);
phi=X(5);
% Values of Job destruction and job creation
JD=delta*unifcdf(eseuil);
JC=theta*(A*theta^(-alpha));
%%RESULTS %%
disp('RESULTS')
disp('')
disp('PARAMETERS VALUES')
disp('')
disp(' ebarh delta kappa z r alpha A gamma rho c ')
disp([ebarh,delta,kappa,z,r,alpha,A,gamma,rho,c]);
disp('')
disp('VARIABLES VALUES')
disp('')
disp(' u theta eseuil tau phi');
disp([u,theta,eseuil,tau,phi]);
disp(' JC JD');
disp('')
disp([JC,JD]);
Thank you, Yann
0 commentaires
Réponses (1)
Torsten
le 8 Mar 2018
Call fsolve in a loop and change the value of rho in this loop according to your needs. Save the results for (theta, eseuil, u ..) in arrays depending on the loop index. As soon as the loop is done, plot the results.
Best wishes
Torsten.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!