Nested for loop for beta and nu
1 view (last 30 days)
Show older comments
So for this problem we were to create a function called SIRode that has 4 inputs and 1 output. The outputs were time t, state y, beta and nu and the output was ydot.
so i created that function to call in the script using the ODE45.
But for beta and nu we have to create a nested for loops to investigate how different values for the parameters beta and nu afftect the simulation results.
- use beta values of 0.005 and 0.05 and nu values of 0.02, 0.04, 0.06 and 0.08 and 0.1 for a total of 10 combinations.
Now I dont understand how to construct this nested loop so my ode45 reader puts the beta and nu each time so i can plot each different one.
attached i have my script and funciton file so far.
Thanks for looking at it for me.
2 Comments
KALYAN ACHARJYA
on 23 Nov 2019
Edited: KALYAN ACHARJYA
on 23 Nov 2019
?So for this problem we were to create a function called SIRode that has 4 inputs and 1 output. The outputs were time t, state y, beta and nu and the output was ydot.
1 output, but again you mentioned that outputs are time t, state y, beta and nu and the output was ydot.
Walter Roberson
on 23 Nov 2019
The rest is just double nested loops.
Answers (1)
Pravin Jagtap
on 25 Nov 2019
From question and code, I assume that you are interested in solving coupled system of ODEs for different parameters. I have following suggestions for achieving the objective:
- Please refer to following link for understanding of how to use ‘ode45’ for solving single ODE. Also, understand how the function handle and arguments are used in the given examplehttps://www.mathworks.com/help/matlab/ref/ode45.html
- Since you have coupled system ODEs, refer to following documentation for understanding how to handle such systems:https://www.mathworks.com/help/symbolic/solve-a-system-of-differential-equations.html
- Use nested ‘for’ loops which will run over the values of ‘beta’ and ‘nu’ vectors and call ‘ode solver’ with proper parameters inside it. The indexing you used is incorrect since ‘for’ loops need integer iterator.
~Pravin
0 Comments
See Also
Categories
Find more on Function Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!