MATLAB Matlab - Change parameters of equation while plot displayed

Click For Summary
The discussion revolves around a user learning MATLAB and seeking ways to interactively adjust parameters in a program that displays differential equations. The user currently must modify the code directly and rerun the program to see changes, which is cumbersome. Suggestions include creating a graphical user interface (GUI) for easier parameter manipulation, though this may require significant effort for a beginner. Alternatives mentioned are writing a script to vary parameters in a loop or creating a function that accepts parameters as inputs. The user acknowledges the need to learn MATLAB more thoroughly, particularly its optimization tools, and expresses interest in using genetic algorithms for modeling. They are also exploring available resources, such as webinars, to enhance their understanding of MATLAB's capabilities.
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
1K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K