Switch Function Is Not Working ProperlyManipulate not working inside DialogInputWhy is slider not working properly in Manipulate?Sequence not working in Manipulate?TrackingFunction not working properly if range contains a mathematical constantCheckbox in manipulate not properly workingWhenEvent StopIntegration not workingManipulate is not workingManipulate[] does not work properlyUsing Which and Switch in a function

How do Ctrl+C and Ctrl+V work?

Why is so much ransomware breakable?

How can I make dummy text (like lipsum) grey?

Roman Numerals Equation 2

Find the area of the rectangle

Can EU citizens work on Iceland?

Thread.sleep inside infinite while loop doesn't throw exception - why?

What is this rubber on gear cables

Single word that parallels "Recent" when discussing the near future

Why does string strummed with finger sound different from the one strummed with pick?

How come Arya Stark didn't burn in Game of Thrones Season 8 Episode 5

Canadian citizen who is presently in litigation with a US-based company

FIFO data structure in pure C

A person lacking money who shows off a lot

Solenoid fastest possible release - for how long should reversed polarity be applied?

Is there an academic word that means "to split hairs over"?

How to know the path of a particular software?

How does this piece of code determine array size without using sizeof( )?

How to handle professionally if colleagues has referred his relative and asking to take easy while taking interview

refer string as a field API name

How can I fix the label locations on my tikzcd diagram?

What are the effects of eating many berries from the Goodberry spell per day?

Why do galaxies collide?

Cycling to work - 30mile return



Switch Function Is Not Working Properly


Manipulate not working inside DialogInputWhy is slider not working properly in Manipulate?Sequence not working in Manipulate?TrackingFunction not working properly if range contains a mathematical constantCheckbox in manipulate not properly workingWhenEvent StopIntegration not workingManipulate is not workingManipulate[] does not work properlyUsing Which and Switch in a function













2












$begingroup$


I'd like to select between the Tent and Hat function to convolve, but my switch function produces an error.



I don't exactly need the initial plots. But I would like to plot the two that I select.



Error Image



(*Defining Tent Funtion*)

Tri[x_, wT_] :=
Piecewise[(1/wT^2)*x + (1/wT),
0 > x > -wT, -(1/wT^2)*x + (1/wT), 0 < x < wT];

(*Defining Top Hat Funtion*)

Hat[x_, wH_] :=
Piecewise[ (1/(2*wH)), 0 > x > -wH, (1/(2*wH)), 0 < x < wH];

(*Defining Incline Funtion*)

(*Plotting & Manipulate Function*)
Manipulate[
pT = Plot[Tri[x, wTent], x, -10, 10, PlotStyle -> Blue,
PlotRange -> All];
pH = Plot[Hat[x, wH], x, -10, 10, PlotStyle -> LightGreen,
PlotRange -> All];
Show[pT, pH, PlotRange -> All, ImageSize -> Medium],
s1 = Switch[fx, "Tent Function", Tri[x + df, wTent],
"Top Hat Function", Hat[x + df, wH]];
s2 = Switch[gx, "Tent Function", Tri[x + dg, wTent],
"Top Hat Function", Hat[x + dg, wH]];
plotConv1 =
Plot[s1, s2, x, -10, 10, Exclusions -> None, PlotRange -> All];
wTent, 1, "Triangle Width", 0.1, 1,
wH, 1, "Top Hat Width", 0.1, 1,
fx, "Tent Function", "Top Hat Function",
df, 0, "Shift fx", -5, 5,
gx, "Tent Function", "Top Hat Function",
dg, -5, "Shift fg", -10, 10
]









share|improve this question











$endgroup$











  • $begingroup$
    Try putting the Show and the plotConv inside something like GraphicsColumn.
    $endgroup$
    – MelaGo
    May 5 at 3:36






  • 1




    $begingroup$
    Immediately following Show[ ... ], change comma to semicolon. (The semicolon will turn red.) Immediately following plotConv1=Plot[ ... ], change semicolon to comma.
    $endgroup$
    – LouisB
    May 5 at 3:36
















2












$begingroup$


I'd like to select between the Tent and Hat function to convolve, but my switch function produces an error.



I don't exactly need the initial plots. But I would like to plot the two that I select.



Error Image



(*Defining Tent Funtion*)

Tri[x_, wT_] :=
Piecewise[(1/wT^2)*x + (1/wT),
0 > x > -wT, -(1/wT^2)*x + (1/wT), 0 < x < wT];

(*Defining Top Hat Funtion*)

Hat[x_, wH_] :=
Piecewise[ (1/(2*wH)), 0 > x > -wH, (1/(2*wH)), 0 < x < wH];

(*Defining Incline Funtion*)

(*Plotting & Manipulate Function*)
Manipulate[
pT = Plot[Tri[x, wTent], x, -10, 10, PlotStyle -> Blue,
PlotRange -> All];
pH = Plot[Hat[x, wH], x, -10, 10, PlotStyle -> LightGreen,
PlotRange -> All];
Show[pT, pH, PlotRange -> All, ImageSize -> Medium],
s1 = Switch[fx, "Tent Function", Tri[x + df, wTent],
"Top Hat Function", Hat[x + df, wH]];
s2 = Switch[gx, "Tent Function", Tri[x + dg, wTent],
"Top Hat Function", Hat[x + dg, wH]];
plotConv1 =
Plot[s1, s2, x, -10, 10, Exclusions -> None, PlotRange -> All];
wTent, 1, "Triangle Width", 0.1, 1,
wH, 1, "Top Hat Width", 0.1, 1,
fx, "Tent Function", "Top Hat Function",
df, 0, "Shift fx", -5, 5,
gx, "Tent Function", "Top Hat Function",
dg, -5, "Shift fg", -10, 10
]









share|improve this question











$endgroup$











  • $begingroup$
    Try putting the Show and the plotConv inside something like GraphicsColumn.
    $endgroup$
    – MelaGo
    May 5 at 3:36






  • 1




    $begingroup$
    Immediately following Show[ ... ], change comma to semicolon. (The semicolon will turn red.) Immediately following plotConv1=Plot[ ... ], change semicolon to comma.
    $endgroup$
    – LouisB
    May 5 at 3:36














2












2








2





$begingroup$


I'd like to select between the Tent and Hat function to convolve, but my switch function produces an error.



I don't exactly need the initial plots. But I would like to plot the two that I select.



Error Image



(*Defining Tent Funtion*)

Tri[x_, wT_] :=
Piecewise[(1/wT^2)*x + (1/wT),
0 > x > -wT, -(1/wT^2)*x + (1/wT), 0 < x < wT];

(*Defining Top Hat Funtion*)

Hat[x_, wH_] :=
Piecewise[ (1/(2*wH)), 0 > x > -wH, (1/(2*wH)), 0 < x < wH];

(*Defining Incline Funtion*)

(*Plotting & Manipulate Function*)
Manipulate[
pT = Plot[Tri[x, wTent], x, -10, 10, PlotStyle -> Blue,
PlotRange -> All];
pH = Plot[Hat[x, wH], x, -10, 10, PlotStyle -> LightGreen,
PlotRange -> All];
Show[pT, pH, PlotRange -> All, ImageSize -> Medium],
s1 = Switch[fx, "Tent Function", Tri[x + df, wTent],
"Top Hat Function", Hat[x + df, wH]];
s2 = Switch[gx, "Tent Function", Tri[x + dg, wTent],
"Top Hat Function", Hat[x + dg, wH]];
plotConv1 =
Plot[s1, s2, x, -10, 10, Exclusions -> None, PlotRange -> All];
wTent, 1, "Triangle Width", 0.1, 1,
wH, 1, "Top Hat Width", 0.1, 1,
fx, "Tent Function", "Top Hat Function",
df, 0, "Shift fx", -5, 5,
gx, "Tent Function", "Top Hat Function",
dg, -5, "Shift fg", -10, 10
]









share|improve this question











$endgroup$




I'd like to select between the Tent and Hat function to convolve, but my switch function produces an error.



I don't exactly need the initial plots. But I would like to plot the two that I select.



Error Image



(*Defining Tent Funtion*)

Tri[x_, wT_] :=
Piecewise[(1/wT^2)*x + (1/wT),
0 > x > -wT, -(1/wT^2)*x + (1/wT), 0 < x < wT];

(*Defining Top Hat Funtion*)

Hat[x_, wH_] :=
Piecewise[ (1/(2*wH)), 0 > x > -wH, (1/(2*wH)), 0 < x < wH];

(*Defining Incline Funtion*)

(*Plotting & Manipulate Function*)
Manipulate[
pT = Plot[Tri[x, wTent], x, -10, 10, PlotStyle -> Blue,
PlotRange -> All];
pH = Plot[Hat[x, wH], x, -10, 10, PlotStyle -> LightGreen,
PlotRange -> All];
Show[pT, pH, PlotRange -> All, ImageSize -> Medium],
s1 = Switch[fx, "Tent Function", Tri[x + df, wTent],
"Top Hat Function", Hat[x + df, wH]];
s2 = Switch[gx, "Tent Function", Tri[x + dg, wTent],
"Top Hat Function", Hat[x + dg, wH]];
plotConv1 =
Plot[s1, s2, x, -10, 10, Exclusions -> None, PlotRange -> All];
wTent, 1, "Triangle Width", 0.1, 1,
wH, 1, "Top Hat Width", 0.1, 1,
fx, "Tent Function", "Top Hat Function",
df, 0, "Shift fx", -5, 5,
gx, "Tent Function", "Top Hat Function",
dg, -5, "Shift fg", -10, 10
]






functions manipulate convolution






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 5 at 15:17









user64494

3,70011222




3,70011222










asked May 5 at 3:00









Lil CoderLil Coder

334




334











  • $begingroup$
    Try putting the Show and the plotConv inside something like GraphicsColumn.
    $endgroup$
    – MelaGo
    May 5 at 3:36






  • 1




    $begingroup$
    Immediately following Show[ ... ], change comma to semicolon. (The semicolon will turn red.) Immediately following plotConv1=Plot[ ... ], change semicolon to comma.
    $endgroup$
    – LouisB
    May 5 at 3:36

















  • $begingroup$
    Try putting the Show and the plotConv inside something like GraphicsColumn.
    $endgroup$
    – MelaGo
    May 5 at 3:36






  • 1




    $begingroup$
    Immediately following Show[ ... ], change comma to semicolon. (The semicolon will turn red.) Immediately following plotConv1=Plot[ ... ], change semicolon to comma.
    $endgroup$
    – LouisB
    May 5 at 3:36
















$begingroup$
Try putting the Show and the plotConv inside something like GraphicsColumn.
$endgroup$
– MelaGo
May 5 at 3:36




$begingroup$
Try putting the Show and the plotConv inside something like GraphicsColumn.
$endgroup$
– MelaGo
May 5 at 3:36




1




1




$begingroup$
Immediately following Show[ ... ], change comma to semicolon. (The semicolon will turn red.) Immediately following plotConv1=Plot[ ... ], change semicolon to comma.
$endgroup$
– LouisB
May 5 at 3:36





$begingroup$
Immediately following Show[ ... ], change comma to semicolon. (The semicolon will turn red.) Immediately following plotConv1=Plot[ ... ], change semicolon to comma.
$endgroup$
– LouisB
May 5 at 3:36











1 Answer
1






active

oldest

votes


















7












$begingroup$

(*Defining Tent Funtion*)
Tri[x_, wT_] :=
Piecewise[
(1/wT^2)*x + (1/wT), 0 > x > -wT,
-(1/wT^2)*x + (1/wT), 0 < x < wT];

(*Defining Top Hat Funtion*)
Hat[x_, wH_] :=
Piecewise[
(1/(2*wH)), 0 > x > -wH,
(1/(2*wH)), 0 < x < wH];

(*Plotting& Manipulate Function*)
Manipulate[
s1 = Switch[fx, "Tent Function", Tri[x + df, wTent],
"Top Hat Function", Hat[x + df, wH]];
s2 = Switch[gx, "Tent Function", Tri[x + dg, wTent],
"Top Hat Function", Hat[x + dg, wH]];
Column[
Plot[
Tri[x, wTent], Hat[x, wH],
x, -10, 10,
PlotStyle -> Blue, Green,
Exclusions -> None,
PlotRange -> All,
ImageSize -> Medium],
Plot[s1, s2, x, -10, 10,
Exclusions -> None,
PlotRange -> All,
ImageSize -> Medium]],
wTent, 1, "Triangle Width", 0.1, 1, Appearance -> "Labeled",
wH, 1, "Top Hat Width", 0.1, 1, Appearance -> "Labeled",
fx, "Tent Function", "Top Hat Function",
df, 0, "Shift fx", -5, 5, Appearance -> "Labeled",
gx, "Tent Function", "Top Hat Function",
dg, -5, "Shift fg", -10, 10, Appearance -> "Labeled",
ControlPlacement -> Bottom]


enter image description here






share|improve this answer









$endgroup$













    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "387"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f197699%2fswitch-function-is-not-working-properly%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    7












    $begingroup$

    (*Defining Tent Funtion*)
    Tri[x_, wT_] :=
    Piecewise[
    (1/wT^2)*x + (1/wT), 0 > x > -wT,
    -(1/wT^2)*x + (1/wT), 0 < x < wT];

    (*Defining Top Hat Funtion*)
    Hat[x_, wH_] :=
    Piecewise[
    (1/(2*wH)), 0 > x > -wH,
    (1/(2*wH)), 0 < x < wH];

    (*Plotting& Manipulate Function*)
    Manipulate[
    s1 = Switch[fx, "Tent Function", Tri[x + df, wTent],
    "Top Hat Function", Hat[x + df, wH]];
    s2 = Switch[gx, "Tent Function", Tri[x + dg, wTent],
    "Top Hat Function", Hat[x + dg, wH]];
    Column[
    Plot[
    Tri[x, wTent], Hat[x, wH],
    x, -10, 10,
    PlotStyle -> Blue, Green,
    Exclusions -> None,
    PlotRange -> All,
    ImageSize -> Medium],
    Plot[s1, s2, x, -10, 10,
    Exclusions -> None,
    PlotRange -> All,
    ImageSize -> Medium]],
    wTent, 1, "Triangle Width", 0.1, 1, Appearance -> "Labeled",
    wH, 1, "Top Hat Width", 0.1, 1, Appearance -> "Labeled",
    fx, "Tent Function", "Top Hat Function",
    df, 0, "Shift fx", -5, 5, Appearance -> "Labeled",
    gx, "Tent Function", "Top Hat Function",
    dg, -5, "Shift fg", -10, 10, Appearance -> "Labeled",
    ControlPlacement -> Bottom]


    enter image description here






    share|improve this answer









    $endgroup$

















      7












      $begingroup$

      (*Defining Tent Funtion*)
      Tri[x_, wT_] :=
      Piecewise[
      (1/wT^2)*x + (1/wT), 0 > x > -wT,
      -(1/wT^2)*x + (1/wT), 0 < x < wT];

      (*Defining Top Hat Funtion*)
      Hat[x_, wH_] :=
      Piecewise[
      (1/(2*wH)), 0 > x > -wH,
      (1/(2*wH)), 0 < x < wH];

      (*Plotting& Manipulate Function*)
      Manipulate[
      s1 = Switch[fx, "Tent Function", Tri[x + df, wTent],
      "Top Hat Function", Hat[x + df, wH]];
      s2 = Switch[gx, "Tent Function", Tri[x + dg, wTent],
      "Top Hat Function", Hat[x + dg, wH]];
      Column[
      Plot[
      Tri[x, wTent], Hat[x, wH],
      x, -10, 10,
      PlotStyle -> Blue, Green,
      Exclusions -> None,
      PlotRange -> All,
      ImageSize -> Medium],
      Plot[s1, s2, x, -10, 10,
      Exclusions -> None,
      PlotRange -> All,
      ImageSize -> Medium]],
      wTent, 1, "Triangle Width", 0.1, 1, Appearance -> "Labeled",
      wH, 1, "Top Hat Width", 0.1, 1, Appearance -> "Labeled",
      fx, "Tent Function", "Top Hat Function",
      df, 0, "Shift fx", -5, 5, Appearance -> "Labeled",
      gx, "Tent Function", "Top Hat Function",
      dg, -5, "Shift fg", -10, 10, Appearance -> "Labeled",
      ControlPlacement -> Bottom]


      enter image description here






      share|improve this answer









      $endgroup$















        7












        7








        7





        $begingroup$

        (*Defining Tent Funtion*)
        Tri[x_, wT_] :=
        Piecewise[
        (1/wT^2)*x + (1/wT), 0 > x > -wT,
        -(1/wT^2)*x + (1/wT), 0 < x < wT];

        (*Defining Top Hat Funtion*)
        Hat[x_, wH_] :=
        Piecewise[
        (1/(2*wH)), 0 > x > -wH,
        (1/(2*wH)), 0 < x < wH];

        (*Plotting& Manipulate Function*)
        Manipulate[
        s1 = Switch[fx, "Tent Function", Tri[x + df, wTent],
        "Top Hat Function", Hat[x + df, wH]];
        s2 = Switch[gx, "Tent Function", Tri[x + dg, wTent],
        "Top Hat Function", Hat[x + dg, wH]];
        Column[
        Plot[
        Tri[x, wTent], Hat[x, wH],
        x, -10, 10,
        PlotStyle -> Blue, Green,
        Exclusions -> None,
        PlotRange -> All,
        ImageSize -> Medium],
        Plot[s1, s2, x, -10, 10,
        Exclusions -> None,
        PlotRange -> All,
        ImageSize -> Medium]],
        wTent, 1, "Triangle Width", 0.1, 1, Appearance -> "Labeled",
        wH, 1, "Top Hat Width", 0.1, 1, Appearance -> "Labeled",
        fx, "Tent Function", "Top Hat Function",
        df, 0, "Shift fx", -5, 5, Appearance -> "Labeled",
        gx, "Tent Function", "Top Hat Function",
        dg, -5, "Shift fg", -10, 10, Appearance -> "Labeled",
        ControlPlacement -> Bottom]


        enter image description here






        share|improve this answer









        $endgroup$



        (*Defining Tent Funtion*)
        Tri[x_, wT_] :=
        Piecewise[
        (1/wT^2)*x + (1/wT), 0 > x > -wT,
        -(1/wT^2)*x + (1/wT), 0 < x < wT];

        (*Defining Top Hat Funtion*)
        Hat[x_, wH_] :=
        Piecewise[
        (1/(2*wH)), 0 > x > -wH,
        (1/(2*wH)), 0 < x < wH];

        (*Plotting& Manipulate Function*)
        Manipulate[
        s1 = Switch[fx, "Tent Function", Tri[x + df, wTent],
        "Top Hat Function", Hat[x + df, wH]];
        s2 = Switch[gx, "Tent Function", Tri[x + dg, wTent],
        "Top Hat Function", Hat[x + dg, wH]];
        Column[
        Plot[
        Tri[x, wTent], Hat[x, wH],
        x, -10, 10,
        PlotStyle -> Blue, Green,
        Exclusions -> None,
        PlotRange -> All,
        ImageSize -> Medium],
        Plot[s1, s2, x, -10, 10,
        Exclusions -> None,
        PlotRange -> All,
        ImageSize -> Medium]],
        wTent, 1, "Triangle Width", 0.1, 1, Appearance -> "Labeled",
        wH, 1, "Top Hat Width", 0.1, 1, Appearance -> "Labeled",
        fx, "Tent Function", "Top Hat Function",
        df, 0, "Shift fx", -5, 5, Appearance -> "Labeled",
        gx, "Tent Function", "Top Hat Function",
        dg, -5, "Shift fg", -10, 10, Appearance -> "Labeled",
        ControlPlacement -> Bottom]


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 5 at 3:42









        Bob HanlonBob Hanlon

        62.5k33599




        62.5k33599



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Mathematica Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f197699%2fswitch-function-is-not-working-properly%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

            What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

            Esgonzo ibérico Índice Descrición Distribución Hábitat Ameazas Notas Véxase tamén "Acerca dos nomes dos anfibios e réptiles galegos""Chalcides bedriagai"Chalcides bedriagai en Carrascal, L. M. Salvador, A. (Eds). Enciclopedia virtual de los vertebrados españoles. Museo Nacional de Ciencias Naturales, Madrid. España.Fotos