I have previously asked a question in regards to determining the labels of the dynamic graph that I have created, but by using SetAttributes
and HoldForm
is unfortunately not doing the trick. Currently this is my code (don't mind the formatting):
FNplot[{f__},
t_, {xmin_, xmax_}, {ymin_, ymax_}] := (functions = {f, {}};
If[ValueQ[number] == False, number = {};];
Manipulate[
Show[Table[
Plot[functions[[k]], {t, xmin, xmax}], {k, 1,
Length[functions]}][[number /. {} ->
Length[functions]]]], {{number, {}, ""},
Thread[Range[Length[functions] - 1] ->
MapThread[
Row[{"Function " <> ToString[#2], Spacer[20]}] &, {ColorData[
97] /@ Range[Length[functions] - 1],
Range[Length[functions] - 1]}]], ControlType -> CheckboxBar,
BaselinePosition -> Center, Method -> "Active",
Appearance -> "Vertical"}, ControlPlacement -> Right])
FNdsin[f_, vp_, ϕ_, d_, swt_, ct_, nct_,
t_] := (s2[n_, T_] :=
vp*Sin[2*Pi*f*(T - d - (n - 1)*ct) + Pi/180*ϕ];
s[n_, T_] := {s2[n, T], d + (n - 1)*ct < T < d + (n - 1)*ct + swt};
Piecewise[Table[s[k, t], {k, 1, nct}]])
FNplot[{FNdsin[1, 1, 90, 0.2, 8.5, 8, 4, t], Cos[t], Tan[t]}, t, {0,
2 Pi}, {-1, 1}]
The last line will produce a graph with slider functionality and checkboxes to plot some functions. I want to replace string Function 1, 2, 3
on the right side with the names of the inputted function by the user (in this case: Function 1
should be FNdsin[1, 1, 90, 0.2, 8.5, 8, 4, t]
, Function 2
should be Cos[t]
and Function 3
should be Tan[t]
.) However,FNdsin[1, 1, 90, 0.2, 8.5, 8, 4, t]
is always evaluated as a piecewise function despite me trying to use HoldForm
, but I would rather show the name of the function and not the evaluation of the function in the legend. How can I do this? Thank you.
HoldFirst
attribute and then you canlabels = Thread[HoldForm[{f}]]
$\endgroup$ – Kuba♦ Aug 31 '16 at 13:03HoldFirst
attribute, are we defining a new function or are we usingf
? $\endgroup$ – Wilson Aug 31 '16 at 13:43SetAttributes[ FNplot, HoldFirst]
. $\endgroup$ – Kuba♦ Aug 31 '16 at 13:45