Nested for loop for beta and nu
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
KALYAN ACHARJYA
2019-11-23
编辑:KALYAN ACHARJYA
2019-11-23
?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
2019-11-23
The rest is just double nested loops.
回答(1 个)
Pravin Jagtap
2019-11-25
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Function Creation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!