I've tried to draw a vector plot with piecewise functions, but it shows empty result.
When I don't use piecewise functions, Vectorplot works well..
I can't figure out what the problem is.
I would really appreciate if someone helps me.
The whole code is below.
A = 5;
b = 0.6;
theta = 0.7;
lambda = 1;
rho = 0.9;
eta = 0.3;
B = 2;
alpha = 1;
i = 0.1;
uppergamma = 1.4;
lowergamma = 0.4;
Delta = 1;
delta = 1;
u[q_] = A q^b;
up[q_] = A b q^(b-1);
F[x_] =
Piecewise[{
{1, x > uppergamma},
{0, x < lowergamma},
{(x-lowergamma)/(uppergamma-lowergamma), lowergamma <= x <= uppergamma}
}];
integrateF[x_] =
Piecewise[{
{0, x < lowergamma},
{x-uppergamma + 0.5, x > uppergamma},
{0.5*(x-lowergamma)^2, lowergamma <= x <= uppergamma}
}];
yinner[n_, i_] = y /. FindRoot[theta*(up[y]-1)/((1-theta)*up[y]+theta) == i/(alpha*n), {y, 0.001}];
y[n_,i_] = If[Im[yinner[n,i]]==0, yinner[n,i], 0];
niso[gamma_] = Max[0, lambda*F[gamma]/(delta+lambda*F[gamma])];
gammaiso[n_] = gamma /.
FindRoot[(rho+delta)*gamma + lambda*integrateF[gamma]
== alpha*(1-theta)*(u[y[n,i]]-y[n,i]), {gamma, 0.001}]
Show[{
ParametricPlot[{n, gammaiso[n]}, {n, 0, 1}, PlotRange -> {{0,1}, {0,uppergamma}},
PlotStyle -> {Blue}, AxesLabel -> {n, gamma},
BaseStyle -> {FontSize -> 12}, PlotLegends -> {Style["gamma_R dot = 0", 12]}],
ParametricPlot[{niso[gamma], gamma}, {gamma, 0, uppergamma}, PlotRange -> {{0,1}, {0,uppergamma}},
PlotStyle -> {Red}, AxesLabel -> {n, gamma},
BaseStyle -> {FontSize -> 12}, PlotLegends -> {Style["ndot=0", 12]}],
VectorPlot[{(1-n)*lambda*F[gamma]-delta*n,
(rho+delta)*gamma + lambda*integrateF[gamma] - alpha *(1-theta)*(u[y[n,i]]-y[n,i])},
{n, 0, 1}, {gamma, 0, uppergamma}]
}]
=
with:=
and it worked. Why are you defining functions with=
and not:=
? always use:=
for functions unless you have specific reason not to. V 13.1 screen shot !Mathematica graphics $\endgroup$