Clear Filters
Clear Filters

Nested for loop for beta and nu

1 view (last 30 days)
brianna roberto
brianna roberto on 22 Nov 2019
Answered: Pravin Jagtap on 25 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.
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
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.

Sign in to comment.

Answers (1)

Pravin Jagtap
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:
  • 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

Categories

Find more on Programming 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!