How to divide the parameters' ranges into subintervals?

8 views (last 30 days)
If I have amodel equation:
dqpldt=fc*Rc*Nc0*exp(Kgr*t)+(fi_Ri*(exp(-di*t)*(Ni0*di-Nc0*ai+Kgr*Ni0))/(Kgr+di))+(Nc0*ai*exp(Kgr*t))/(Kgr+di)-Ke*qpl;
With parameters' ranges:
fc=[10^(-4),1]; Rc= [4.5*10^(-11),0.45]; Nc0=[1,10^(10)]; Kgr= [3.46*10^(-3),0.578]; and so on for the remaining parameters fi_Ri; ai; di; Ni0; Ke;
For each parameter, how can I divide the range into 21 subintervals using equally spaced nodes and calculate the time (t) at each node, while the other parameters' values are fixed at the baseline?
For the baseline values, I used the following code to obtain the corresponding time (t):
syms qpl(t)
qpl(t)= exp(5.78*10^(-3)*t)*((0.0474*1/((5.78*10^(-3)+0.1131)*(2.14+5.78*10^(-3))))+(0.1*4.5*10^(-5)*1/(2.14+5.78*10^(-3))))+exp(-0.1131*t)*((10.925*10^(-6)*1/(2.14-0.1131))-(10.925*10^(-6)*0.0474*1/((5.78*10^(-3)+0.1131)*(2.14-0.1131))))+exp(-2.14*t)*(((0.1*4.5*10^(-5)*1)/(5.78*10^(-3)+2.14))+((10.925*10^(-6)*0.0474*1)/((5.78*10^(-3)+0.1131)*(2.14-0.1131)))-(10.925*10^(-6)*1/(2.14-0.1131))-(0.0474*1/((5.78*10^(-3)+0.1131)*(5.78*10^(-3)+2.14))))-(3150*1)==0;
sol = vpasolve(qpl)
Thanks in advance, Esraa.

Accepted Answer

John D'Errico
John D'Errico on 12 Feb 2017
Edited: John D'Errico on 12 Feb 2017
So, you have how many parameters?
fc*Rc*Nc0*exp(Kgr*t)+(fi_Ri*(exp(-di*t)*(Ni0*di-Nc0*ai+Kgr*Ni0))/(Kgr+di))+(Nc0*ai*exp(Kgr*t))/(Kgr+di)-Ke*qpl;
The list of parameters looks like:
fc,Rc,Nc0,Kgr,fi_Ri,di,Ni0,Nc0, ai,Ke,qpl
11 of them by my count, if I did not miss any.
Now you want to create a a 21x21x21x21x21...x21 set of all combinations of each parameter, so 21^11.
21^11
ans =
3.502775005422210e+14
Only 353 trillion combinations of all those parameters. Oh, and then you want to use vpasolve on EVERY combination, to solve for t.
If that is your goal, then it is patently silly. My guess is that it is not how I should be interpreting your somewhat confusing question.
Is this a case where you simply want to fix all those parameters but one, with one single parameter ranging over the entire range provided, then just loop over each parameter range. HINT:
doc linspace
Given the wide dynamic range of those parameters, you may want to learn to use logspace instead.
doc logspace
I don't see what is your problem. Use linspace/logspace to generate a set of values in the range indicated. Then it is just a loop, with the other parameters held fixed. So what if you write the code more than once? A more creative and clean solution would have you just create the set of all the values in one operation using interpolation, and loop over the solves.
Finally, a bette yet solution would see that most of your parameters enter in trivially. If you have one basic solution, then changing any of the parameters changes that solution in a trivial way. It is often the case that simple mathematics is sufficient to change a difficult problem into a very easy one.
For example, each of fc,Rc, and NC0 appear in exactly one place, as simple multipliers. Double any one of them, and the solution has exactly the same behavior.

More Answers (0)

Categories

Find more on Loops and Conditional Statements 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!