Matlab - Change parameters of equation while plot displayed

Click For Summary

Discussion Overview

The discussion centers on how to interactively change parameters in a MATLAB program that displays differential equations, allowing users to see the effects on the graph without needing to modify the code and rerun the program. The scope includes programming techniques in MATLAB, particularly focusing on GUI development and optimization tools.

Discussion Character

  • Exploratory
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • Dave K expresses a desire to change parameters interactively in a MATLAB program displaying differential equations, rather than modifying the code directly.
  • Josh suggests that creating a GUI could facilitate interactive parameter adjustment, though it may require significant effort for a beginner.
  • Josh also proposes alternatives such as writing a script to vary parameters in a loop or creating a function that accepts parameters as inputs.
  • Dave K acknowledges the need to learn MATLAB more thoroughly and reflects on the differences between mathematical modeling in MATLAB versus Maple.
  • Dave K mentions an interest in using optimization tools and resources available for learning about genetic algorithms.

Areas of Agreement / Disagreement

Participants do not reach a consensus on a specific solution for interactive parameter adjustment, as multiple approaches are discussed and no definitive method is agreed upon.

Contextual Notes

Dave K's initial question stems from a misunderstanding of MATLAB's capabilities, indicating a need for foundational knowledge in MATLAB programming and optimization techniques.

Who May Find This Useful

Individuals learning MATLAB, particularly those interested in programming interactive models or optimization techniques in scientific computing.

dkotschessaa
Messages
1,063
Reaction score
763
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
 
Physics news on Phys.org
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:
kreil said:
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

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
 
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
 
Last edited by a moderator:

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K