Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4340220
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:19:12+00:00 2026-05-21T11:19:12+00:00

Mathematica provides many functions which are capable of handling Dynamic as an argument. For

  • 0

Mathematica provides many functions which are capable of handling Dynamic as an argument.
For example, the function FileNameSetter has the following variant:

FileNameSetter[Dynamic[name]] 
 uses the dynamically updated current value of name, with the 
 value of name being reset if a different file is chosen.

I wonder how one goes about defining a function pattern that takes a dynamic expression as an argument. For example, here is one attempt to wrap the dynamic variant of the function LocatorPane:

SinLocatorPane[Dynamic[sinvalue_]] := 
 LocatorPane[Dynamic[x, (x = #; sinvalue = Sin[First[#]]) &], 
             Plot[Sin[x], {x, 0, 10}]]

What is the correct pattern to use for a dynamic expression argument? Are there any caveats with using the dynamic argument inside the function definition?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:19:13+00:00Added an answer on May 21, 2026 at 11:19 am

    If you would like to write a function that updates the value of a certain variable, this is like passing a variable by reference. Standard way of achieving this in Mathematica is to use Hold* attributes on your function.

    SetAttributes[SinLocatorPane, HoldFirst];
    SinLocatorPane[sinvalue_] := 
     LocatorPane[Dynamic[x, (x = #; sinvalue = Sin[First[#]]) &], 
      Plot[Sin[x], {x, 0, 10}]]
    

    Then

    {Dynamic[sv], SinLocatorPane[sv]}
    

    would work as your expected. Your code worked because Dynamic has HoldFirst attributed and this allowed your code to update variable sinvalue. Otherwise Dynamic was not really needed

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the following query to determine how many votes a story has received:
Is there a Mathematica function that provides results equivalent to the unique() function in
I'm using Mathematica 7. I have an interpolated function, here's an example: pressures =
In many symbolic math systems, such as Matlab or Mathematica, you can use a
For better or worse, Mathematica provides a wealth of constructs that allow you to
I need to implement an algorithm which has intensive mathematical calculation. Is there already
In Mathematica, how do you change the order of importance of variables? for example:
If you have Mathematica code in foo.m, Mathematica can be invoked with -noprompt and
Many languages of REPL consoles with additional features like autocomplete and intellisense. For instance,
The Situation: I'm optimizing a pure-java implementation of the LZF compression algorithm, which involves

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.