How to change number of steps of solutions with ode45 - Matlab? [closed]












0












$begingroup$


I have the next function:



function [f,R]=fun_z_proba(z,p,beta)  % function definition
ri=0.7;
R=ri-z*(ri-1);
f=zeros(4,size(p,2));
f(1,:)=-32.*beta./(R.^4.*p(1,:));
f(2,:)=(-8*f(1,:)./R-f(1,:).*p(2,:))./p(1,:);
f(3,:)=(-p(2,:).*f(2,:)-8.*f(2,:)./R-8.*f(1,:)./(R.*R.*p(1,:))-f(1,:).*p(3,:))./p(1,:);
f(4,:)=(-f(2,:).*p(3,:)-f(3,:).*p(2,:)+8.*(-f(3,:)./R- (f(2,:)./p(1,:)-p(2,:).*f(1,:)./(p(1,:).*p(1,:)))./(R.*R)) -f(1,:).*p(4,:))./p(1,:);
end


and I am calling it with



beta=1:0.1:5;
f=cell(1,numel(beta));
ctr=1;
for beta = beta
[f{ctr},p{ctr}]=ode45(@(z,p)fun_z_proba(z,p,beta), [1 0], [1; 0; 0; 0]);
ctr=ctr+1;
end


Results important for me are stored in p, but for every value of beta I got different number of values for p. Is there some way to get the same number of p values in every case for beta, under the same conditions like here?










share|cite|improve this question











$endgroup$



closed as off-topic by Tony S.F., pre-kidney, A. Pongrácz, Riccardo.Alestra, José Carlos Santos Jan 15 at 9:34


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question is not about mathematics, within the scope defined in the help center." – Tony S.F., Riccardo.Alestra, José Carlos Santos

If this question can be reworded to fit the rules in the help center, please edit the question.












  • 2




    $begingroup$
    This seems to be a question about some programming language, not a question about mathematics, right? So, maybe it should be posted to a coding site, instead?
    $endgroup$
    – Gerry Myerson
    Jan 14 at 15:05










  • $begingroup$
    Which one coding site?
    $endgroup$
    – nick_name
    Jan 14 at 15:19










  • $begingroup$
    stackoverflow.com is the coding site. "Code review" exists for improvements on working code, "scientific computing" for algorithmic questions.
    $endgroup$
    – LutzL
    Jan 14 at 15:47
















0












$begingroup$


I have the next function:



function [f,R]=fun_z_proba(z,p,beta)  % function definition
ri=0.7;
R=ri-z*(ri-1);
f=zeros(4,size(p,2));
f(1,:)=-32.*beta./(R.^4.*p(1,:));
f(2,:)=(-8*f(1,:)./R-f(1,:).*p(2,:))./p(1,:);
f(3,:)=(-p(2,:).*f(2,:)-8.*f(2,:)./R-8.*f(1,:)./(R.*R.*p(1,:))-f(1,:).*p(3,:))./p(1,:);
f(4,:)=(-f(2,:).*p(3,:)-f(3,:).*p(2,:)+8.*(-f(3,:)./R- (f(2,:)./p(1,:)-p(2,:).*f(1,:)./(p(1,:).*p(1,:)))./(R.*R)) -f(1,:).*p(4,:))./p(1,:);
end


and I am calling it with



beta=1:0.1:5;
f=cell(1,numel(beta));
ctr=1;
for beta = beta
[f{ctr},p{ctr}]=ode45(@(z,p)fun_z_proba(z,p,beta), [1 0], [1; 0; 0; 0]);
ctr=ctr+1;
end


Results important for me are stored in p, but for every value of beta I got different number of values for p. Is there some way to get the same number of p values in every case for beta, under the same conditions like here?










share|cite|improve this question











$endgroup$



closed as off-topic by Tony S.F., pre-kidney, A. Pongrácz, Riccardo.Alestra, José Carlos Santos Jan 15 at 9:34


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question is not about mathematics, within the scope defined in the help center." – Tony S.F., Riccardo.Alestra, José Carlos Santos

If this question can be reworded to fit the rules in the help center, please edit the question.












  • 2




    $begingroup$
    This seems to be a question about some programming language, not a question about mathematics, right? So, maybe it should be posted to a coding site, instead?
    $endgroup$
    – Gerry Myerson
    Jan 14 at 15:05










  • $begingroup$
    Which one coding site?
    $endgroup$
    – nick_name
    Jan 14 at 15:19










  • $begingroup$
    stackoverflow.com is the coding site. "Code review" exists for improvements on working code, "scientific computing" for algorithmic questions.
    $endgroup$
    – LutzL
    Jan 14 at 15:47














0












0








0





$begingroup$


I have the next function:



function [f,R]=fun_z_proba(z,p,beta)  % function definition
ri=0.7;
R=ri-z*(ri-1);
f=zeros(4,size(p,2));
f(1,:)=-32.*beta./(R.^4.*p(1,:));
f(2,:)=(-8*f(1,:)./R-f(1,:).*p(2,:))./p(1,:);
f(3,:)=(-p(2,:).*f(2,:)-8.*f(2,:)./R-8.*f(1,:)./(R.*R.*p(1,:))-f(1,:).*p(3,:))./p(1,:);
f(4,:)=(-f(2,:).*p(3,:)-f(3,:).*p(2,:)+8.*(-f(3,:)./R- (f(2,:)./p(1,:)-p(2,:).*f(1,:)./(p(1,:).*p(1,:)))./(R.*R)) -f(1,:).*p(4,:))./p(1,:);
end


and I am calling it with



beta=1:0.1:5;
f=cell(1,numel(beta));
ctr=1;
for beta = beta
[f{ctr},p{ctr}]=ode45(@(z,p)fun_z_proba(z,p,beta), [1 0], [1; 0; 0; 0]);
ctr=ctr+1;
end


Results important for me are stored in p, but for every value of beta I got different number of values for p. Is there some way to get the same number of p values in every case for beta, under the same conditions like here?










share|cite|improve this question











$endgroup$




I have the next function:



function [f,R]=fun_z_proba(z,p,beta)  % function definition
ri=0.7;
R=ri-z*(ri-1);
f=zeros(4,size(p,2));
f(1,:)=-32.*beta./(R.^4.*p(1,:));
f(2,:)=(-8*f(1,:)./R-f(1,:).*p(2,:))./p(1,:);
f(3,:)=(-p(2,:).*f(2,:)-8.*f(2,:)./R-8.*f(1,:)./(R.*R.*p(1,:))-f(1,:).*p(3,:))./p(1,:);
f(4,:)=(-f(2,:).*p(3,:)-f(3,:).*p(2,:)+8.*(-f(3,:)./R- (f(2,:)./p(1,:)-p(2,:).*f(1,:)./(p(1,:).*p(1,:)))./(R.*R)) -f(1,:).*p(4,:))./p(1,:);
end


and I am calling it with



beta=1:0.1:5;
f=cell(1,numel(beta));
ctr=1;
for beta = beta
[f{ctr},p{ctr}]=ode45(@(z,p)fun_z_proba(z,p,beta), [1 0], [1; 0; 0; 0]);
ctr=ctr+1;
end


Results important for me are stored in p, but for every value of beta I got different number of values for p. Is there some way to get the same number of p values in every case for beta, under the same conditions like here?







ordinary-differential-equations functions matlab






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Jan 14 at 15:18







nick_name

















asked Jan 14 at 14:32









nick_namenick_name

1299




1299




closed as off-topic by Tony S.F., pre-kidney, A. Pongrácz, Riccardo.Alestra, José Carlos Santos Jan 15 at 9:34


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question is not about mathematics, within the scope defined in the help center." – Tony S.F., Riccardo.Alestra, José Carlos Santos

If this question can be reworded to fit the rules in the help center, please edit the question.







closed as off-topic by Tony S.F., pre-kidney, A. Pongrácz, Riccardo.Alestra, José Carlos Santos Jan 15 at 9:34


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question is not about mathematics, within the scope defined in the help center." – Tony S.F., Riccardo.Alestra, José Carlos Santos

If this question can be reworded to fit the rules in the help center, please edit the question.








  • 2




    $begingroup$
    This seems to be a question about some programming language, not a question about mathematics, right? So, maybe it should be posted to a coding site, instead?
    $endgroup$
    – Gerry Myerson
    Jan 14 at 15:05










  • $begingroup$
    Which one coding site?
    $endgroup$
    – nick_name
    Jan 14 at 15:19










  • $begingroup$
    stackoverflow.com is the coding site. "Code review" exists for improvements on working code, "scientific computing" for algorithmic questions.
    $endgroup$
    – LutzL
    Jan 14 at 15:47














  • 2




    $begingroup$
    This seems to be a question about some programming language, not a question about mathematics, right? So, maybe it should be posted to a coding site, instead?
    $endgroup$
    – Gerry Myerson
    Jan 14 at 15:05










  • $begingroup$
    Which one coding site?
    $endgroup$
    – nick_name
    Jan 14 at 15:19










  • $begingroup$
    stackoverflow.com is the coding site. "Code review" exists for improvements on working code, "scientific computing" for algorithmic questions.
    $endgroup$
    – LutzL
    Jan 14 at 15:47








2




2




$begingroup$
This seems to be a question about some programming language, not a question about mathematics, right? So, maybe it should be posted to a coding site, instead?
$endgroup$
– Gerry Myerson
Jan 14 at 15:05




$begingroup$
This seems to be a question about some programming language, not a question about mathematics, right? So, maybe it should be posted to a coding site, instead?
$endgroup$
– Gerry Myerson
Jan 14 at 15:05












$begingroup$
Which one coding site?
$endgroup$
– nick_name
Jan 14 at 15:19




$begingroup$
Which one coding site?
$endgroup$
– nick_name
Jan 14 at 15:19












$begingroup$
stackoverflow.com is the coding site. "Code review" exists for improvements on working code, "scientific computing" for algorithmic questions.
$endgroup$
– LutzL
Jan 14 at 15:47




$begingroup$
stackoverflow.com is the coding site. "Code review" exists for improvements on working code, "scientific computing" for algorithmic questions.
$endgroup$
– LutzL
Jan 14 at 15:47










1 Answer
1






active

oldest

votes


















2












$begingroup$

If you want values at fixed locations, call the method with these locations in the place of tspan.



You could also use the dense output option to have an interpolation function over the whole interval. See Matlab documentation how to invoke it and use its result.






share|cite|improve this answer









$endgroup$




















    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2












    $begingroup$

    If you want values at fixed locations, call the method with these locations in the place of tspan.



    You could also use the dense output option to have an interpolation function over the whole interval. See Matlab documentation how to invoke it and use its result.






    share|cite|improve this answer









    $endgroup$


















      2












      $begingroup$

      If you want values at fixed locations, call the method with these locations in the place of tspan.



      You could also use the dense output option to have an interpolation function over the whole interval. See Matlab documentation how to invoke it and use its result.






      share|cite|improve this answer









      $endgroup$
















        2












        2








        2





        $begingroup$

        If you want values at fixed locations, call the method with these locations in the place of tspan.



        You could also use the dense output option to have an interpolation function over the whole interval. See Matlab documentation how to invoke it and use its result.






        share|cite|improve this answer









        $endgroup$



        If you want values at fixed locations, call the method with these locations in the place of tspan.



        You could also use the dense output option to have an interpolation function over the whole interval. See Matlab documentation how to invoke it and use its result.







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Jan 14 at 15:44









        LutzLLutzL

        58.7k42055




        58.7k42055















            Popular posts from this blog

            Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

            Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

            A Topological Invariant for $pi_3(U(n))$