(*Nasser M. Abbasi, 9/28.2015*)
Manipulate[
Module[{x},
g[x_, r_, k_] := r - x/k;
f[x_] :=
Piecewise[{{-0.5,
x <= -1.0}, {x + 1/2, -1 <= x <= -1/2}, {0, -1/2 <= x <=
1/2}, {x - 1/2, 1/2 <= x <= 1}, {1/2, x > 1}}];
data = First@Last@Reap[Do[
sol = x /. First@NSolve[f[x] == g[x, r, k], x];
Sow[{r, f[sol]}],
{r, -2, 2, .2}
]
];
Grid[{
{Row[{Text@
Style["Red color is linearized device output using feedback",
Medium]}]},
{
Show[Plot[f[x], {x, -2, 2}, Exclusions -> None],
ListLinePlot[data, PlotStyle -> Red], ImageSize -> 400,
GridLines -> Automatic]
}}
]
],
{{k, 1, "k"}, 1, 20, .1, Appearance -> "Labeled"},
TrackedSymbols :> {k}
]