Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab - Change parameters of equation while plot displayed

Tags:
  1. Jun 16, 2014 #1
    First note that I am just learning Mat lab, and running a program created by someone else.

    I have a program which is displaying four differential equations on screen, all with various parameters assigned in the beginning. i.e.

    alpha=10;
    beta=0.04;
    gamma=0.020;

    etc.

    For equations of the form:
    dy(1) = alpha*y(1)*(1-power(y(1)/y(4),1))-beta*y(1)-gamma*y(3)*y(1);

    which are being called from a separate file.

    I want to be able to change these parameters interactively somehow to see how it effects the graph. Right now I have to go into the code, change the parameter and run again. Is there a way to do this?

    Thanks.

    Dave K
     
  2. jcsd
  3. Jun 17, 2014 #2

    kreil

    User Avatar
    Gold Member

    Hi Dave,

    I expect that in order to achieve interactive parameter adjustment, you'll have to program a GUI. If you're new to MATLAB, doing so might require much more work than just changing parameters and rerunning the program. Nevertheless, it might be worth the time investment for reuse later, and there is plenty of documentation available to help. For example, here is an introductory topic on GUI building: http://www.mathworks.com/help/matlab/creating_guis/about-the-simple-guide-gui-example.html

    There are other options though. You could simply write a script where you vary the parameters within a loop and overlay the different plots, or you could write your own function that takes the parameters as inputs and uses nested functions to define the equations. Then you could call that function from the command line to solve the equations with whatever parameter values you want.

    Hope this helps.
    Josh
     
    Last edited: Jun 17, 2014
  4. Jun 19, 2014 #3
    Thanks for your reply. I realize that I really need to learn Matlab from scratch, and that much of the point of matlab is to try to fit models to experimental data. So my question doesn't even really make sense, now that I know this. I'm used to doing mathy math (in maple) rather than sciency math (in matlab).

    As you said, I have to invest more time learning how to do it than doing it, but it'll be worth it. I think we're going to use a genetic algorithm. Don't know how to do that yet, but I see videos and such available.

    Thanks,

    Dave K
     
  5. Jun 26, 2014 #4
    For anyone's future reference, this is apparently about my newbie misunderstanding of what Matlab does. What I think I need are the optimization tools. Currently going through this webinar:

    Global Optimization with MATLAB Products:
    http://www.mathworks.com/videos/global-optimization-with-matlab-products-81716.htmll [Broken]
     
    Last edited by a moderator: May 6, 2017
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Matlab - Change parameters of equation while plot displayed
  1. Plotting with MATLAB (Replies: 1)

  2. MatLab Plot (Replies: 6)

Loading...