MATLAB: Is it possible to specify length of an array that is a result from ode15s

differential equationsode15s

I have a ode15s function solving equations in a loop for different parameters. I have to plot all my results in one plot, so I have to have all results in one array. Here's my code:
dn=0.0:(N/100):N;
ALFA=[];
alfa0=0;
zspan=[0 1];
for B=0.1:0.1:1.0;
ZERO=[];
for i=1:101
alfapocz=alfa0+dn(i);
alfak=alfapocz/B;
[z,alfa]=ode15s('poch',zspan,alfapocz);
[m,n]=size(alfa);
alfakonc=alfa(m,n);
F=abs(alfakonc-alfak);
ZERO=[ZERO F];
end
[M,I]=min(ZERO);
alfapocz=dn(I);
zspan=[0 1];
[z,alfa]=ode15s('poch',zspan,alfapocz);
ALFA=[ALFA alfa];
end
My problem is in the end – I try to put all my results in one matrix but ode15s gives results as different arrays (different lengths) and I don't know how to change that (if it's even possible).

Best Answer

If you define "zspan" as a vector with more than two elements, ode15s outputs the solution exactly at the z-values specified in "zspan". This will make your output arrays compatible.
Best wishes
Torsten.
Related Question