i ran into a strange error when trying to solve a set of odes. when my code was working fine, i tried changing one of my parameters that appear in the equations from 1 to some higher value (say 2 for example) and i get the following error:
Error using horzcat Dimensions of matrices being concatenated are not consistent.
Error in ode15s (line 821) ieout = [ieout, ie];
Error in test (line 149) (test is my file name)
im not sure what this error means, and what is the cause of it, since for exactly the same code i get no such error when one of my parameters is slightly lower. i also noted that if assign this parameter a much higher value like 100 or 1000 the code will run without giving me error, so i have no idea what is wrong since the code was working fine. i also see no reason as to why 1 or 100 would be good values and 2 or 10 wouldn't, since this parameter (lets call it alpha) will play the following role ( this isnt exact, but close to the exact solution ): one of my function will behave as follows:
y(x)=A*exp( alpha*(x-x_0) )+B
where A,B,x_0 are constants and alpha is my parameter. so if alpha=1,100 is fine why wouldnt alpha=2,10 be fine? makes no sense to me.
i have my suspicions as to what is causing the probelm. i opened another thread regarding things related to that, and i have not received an answer yet. so i think it would be of great help if you can answer me here:
i am solving for x>0 and x<0 separetly because i have an initial condition for x=0, and i want the solution in both x>0 and x<0. the discontinuities are actually in the points where the function Gamma_tilde_a(y(4))=1 or Gamma_tilde_a(y(5))=1 as i specified in the event function:
function Gamma_tilde_a=Gamma_tilde_a(u_tilde_a)
Gamma_tilde_a=(Gamma_thr^-2+u_tilde_a.^2).^(1/2);
end
function [condition_pp,indicator_terminate_pp,direction_pp]=pair_production_and_stopping_points(x,y)
condition_pp=[Gamma_tilde_a(y(4))-1,Gamma_tilde_a(y(5))-1,abs(y(4))-u_tilde_a_stop_tol,abs(y(5))-u_tilde_a_stop_tol];
indicator_terminate_pp=[0,0,1,1];
direction_pp=[0,0,0,0];
end
say the first event point is x_0, so in my code i first solve from x=0 to x=x_0 (using the event function to terminate the integration at x=x_0) then i solve again from x_0 to some final x value x_final. after this is done, i do the exact same thing for the x<0 zone. the error message occurs when solving for x>0 and just a little after x=x_0 (so this is before even reaching the part where it solves for x<0).
now the thing is, as i said, when i solve from x=0 to x_0 i make sure i terminate at x=x_0 using the event function, because i want to enforce a new initial condition at the point x=x_0. when i then continue to solve from x=x_0 to x_final i don't really want to terminate at any point, but the condition Gamma_tilde_a(y(4)=1 or Gamma_tilde_a(y(5))=1 may still happen so i may end up with more discontinuous points. for this reason, i used the event function and specified the events Gamma_tilde_a(y(4))=1, Gamma_tilde_a(y(5))=1 , but i didnt make it terminate. now i need to know if specifying the discontinuous points as an event in itself actually does anything in regards to dealing with the discontinuities, or do i have to terminate each time an event occurs (without knowing in advance how many times the event might occur)? so maybe i should try making a while loop that will make the integration terminate at each event point, and as long as the numel(y_event) for the y_event the ode solver returns from each time it stopped at an event point isnt zero, it will continue to integrate and terminate at each event point??
by the way, just to make things clearer, the reason that those event points are discontinuous is because i have the function:
function alpha_tilde_a=alpha_tilde_a(u_tilde_a)
if Gamma_tilde_a(u_tilde_a)<=1
alpha_tilde_a=0;
else
alpha_tilde_a=alpha_parameter;
end
end
which appears in my equations.