Effacer les filtres
Effacer les filtres

Strange error when trying to solve a set of ODEs

7 vues (au cours des 30 derniers jours)
tensorisation
tensorisation le 18 Jan 2016
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) % a function that expresses the normalized gamma factor (normalized with Gamma_thr) in terms of 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) % the event that specify for the ode solver when pair production occurs , applied for both the positrons and electrons after the 1st pair production had already occured %
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]; % for the first two components of this vector : when this value is zero, the pair production event occurs , the last two component of this vector: checking for the stopping point of the positrons (which for them will occur in the s_tilde>0 zone) and the electrons (which for them will occur in the s_tilde<0 zone) %
indicator_terminate_pp=[0,0,1,1]; % 0 - the solver does not terminate when the event occurs , 1 - the solver does terminate when the event occurs %
direction_pp=[0,0,0,0]; % 0 - all zeros are to be located, regardless if the event function is increasing or decreasing , +1 - only for zeros where the event function is increasing , -1 - only for zeros where the event function is decreasing %
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) % a function for alpha_tilde_a that appears in the expressions for the source terms %
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.

Réponses (2)

Star Strider
Star Strider le 18 Jan 2016
If it works in some situations and not others, it usually means that the row or column of the vector being added contains an empty value, so the length of the vector is less than the others. It will probably be worthwhile to use the debugging tools to see where the problem occurs.
  31 commentaires
Star Strider
Star Strider le 28 Jan 2016
That’s the problem with difficult Questions. There are a few MathWorks staffers who show up here, but the rest of us are unpaid volunteers.
You can use the ‘Contact Support’ link (See ‘Contact Us’ at the top right corner of this page), and see if MathWorks can help. They will if it’s a question about a specific function (in this instance the ‘event’ option in your ODE solver, if that’s actually the problem), so putting it in those terms could help. Reference the URL to this thread in your question to them so they don’t have to search for it and so you don’t have to repeat all of it. I haven’t seen your other post, so you may want to reference it as well.
That’s the best I can do.
Nicolas Mira Gebauer
Nicolas Mira Gebauer le 6 Août 2020
Hi, I am getting a very similar problem, although 4 and a half years later... How did you solve your problem?
Thank you very much

Connectez-vous pour commenter.


John BG
John BG le 18 Jan 2016
could you please start by hanging the complete code you use?
the one that results into the error code you have already described in detail.
Awaiting answer
John
  2 commentaires
tensorisation
tensorisation le 19 Jan 2016
Modifié(e) : tensorisation le 19 Jan 2016
well, in my experience if i give my complete code people don't bother reading it, but here you go:
format long g; % using a display format that will give an output in a more convenient manner, in case there is a check/test that we want to make %
% natrual constants %
c=2.988*10^10; % speed of light in cm/s %
e=4.8032*10^-10; % the electrical charge of the electron, in units of statC %
m_e=9.10938*10^-28; % the mass of the electron, in units of g %
hbar=1.054572*10^-27; % the reduced Plank constant, in units of erg*s %
alpha=e^2/(hbar*c); % the fine structure constant, a unitless quantity %
G=6.67*10^-8; % Newton's gravitational constant, in units of dyne*cm^2*g^-2 %
M_sun=1.988*10^33; % the mass of the sun in g %
% parameters/constants related to the blackhole itself %
lambda=asin(0.9); % sin(lambda) represents the normalized angular momentum of the blackhole %
M=M_sun*10^9; % the mass of the blackhole %
r_H=G*M*(c^-2)*(1+cos(lambda)); % the radius for the blackhole horizon, in units of cm %
Omega_H=(c^3/(2*G*M))*tan(lambda/2); % the angular velocity of the blackhole horizon, in units of s^-1 %
% additional parameters/constants %
B=10^4; % the typical magnetic field in our area of interest, in units of G (Gauss)%
rho_rot=(Omega_H*B)/(4*pi*c); % the Goldreich-Julian charge density, in units of statC/cm^3 %
rho_B=r_H; % the curvature radius of the magnetic field lines, in units of cm %
omega_B=sqrt((4*pi*e*rho_rot)/m_e); % a characteristic frequency scale in our model %
L_B=c/omega_B; % a characteristic length scale in our model %
Gamma_thr=10^6; % the effective Lorentz factor threshold for the pair production process %
C_1=(4/9)*alpha*L_B*Gamma_thr*r_H^-1; % one of the dimensionless constants i introduced in the expressions for the source terms %
C_2=(e*Gamma_thr^4)/(4*pi*r_H^2*L_B*rho_rot); % one of the dimensionless constants i introduced in the expressions for the source terms %
h_tilde_a=Gamma_thr; % the normalized enthalpy per particle for each species of fluid (in the rest frame of the fluid) %
function beta_a=beta_a(u_tilde_a) % a function that expresses the normalized velocity (normalized with c) in terms of u_tilde_a %
beta_a=u_tilde_a.*(Gamma_thr^-2+u_tilde_a.^2).^(-1/2);
end
function Gamma_tilde_a=Gamma_tilde_a(u_tilde_a) % a function that expresses the normalized gamma factor (normalized with Gamma_thr) in terms of u_tilde_a %
Gamma_tilde_a=(Gamma_thr^-2+u_tilde_a.^2).^(1/2);
end
function E_gamma_a=E_gamma_a(u_tilde_a) % a function for the typical energy of a CR (curvature radiation, which is also called synchrotron radiation) photon in terms of u_tilde_a %
E_gamma_a=(2/3)*(C_2/C_1)*Gamma_tilde_a(u_tilde_a).^3;
end
% changing these 2 parameters in order to find a steady state solution %
alpha_parameter=1;
xi=10^-2;
function alpha_tilde_a=alpha_tilde_a(u_tilde_a) % a function for alpha_tilde_a that appears in the expressions for the source terms %
if Gamma_tilde_a(u_tilde_a)<=1
alpha_tilde_a=0;
else
alpha_tilde_a=alpha_parameter;
end
end
%}
%{
function alpha_tilde_a=alpha_tilde_a(u_tilde_a) % a function for alpha_tilde_a that appears in the expressions for the source terms %
if Gamma_tilde_a(u_tilde_a)<=1
alpha_tilde_a=0;
else
alpha_tilde_a=C_1*Gamma_tilde_a(u_tilde_a);
end
end
%}
function q_tilde_a=q_tilde_a(n_tilde_lab_a,n_tilde_lab_plus,n_tilde_lab_minus,u_tilde_plus,u_tilde_minus) % a function for the source term q_tilde_a %
q_tilde_a=(1./(2*n_tilde_lab_a)).*(n_tilde_lab_plus.*alpha_tilde_a(u_tilde_plus)+n_tilde_lab_minus.*alpha_tilde_a(u_tilde_minus));
end
function s_tilde_1_a=s_tilde_1_a(u_tilde_a) % a function for the source term s_tilde_1_a %
s_tilde_1_a=C_2*(Gamma_tilde_a(u_tilde_a).^3).*u_tilde_a;
end
function q_tilde_1_a=q_tilde_1_a(n_tilde_lab_a,n_tilde_lab_plus,n_tilde_lab_minus,u_tilde_plus,u_tilde_minus) % a function for the source term q_tilde_1_a %
q_tilde_1_a=(1./(2*n_tilde_lab_a)).*(n_tilde_lab_plus.*alpha_tilde_a(u_tilde_plus).*E_gamma_a(u_tilde_plus)+n_tilde_lab_minus.*alpha_tilde_a(u_tilde_minus).*E_gamma_a(u_tilde_minus));
end
function D_eqs_before_1st_pp=D_eqs_before_1st_pp(x,y) % a function that describe the diffrential equations for the solver function of matlab that solves the equations, with x=s , y=[E_tilde_par ; n_tilde_lab_plus ; n_tilde_lab_minus ; u_tilde_plus ; u_tilde_minus] , D_eqs=dy/dx %
D_eqs_before_1st_pp=zeros(5,1);
if x>0 % for s_tilde>0 where there are no initial positrons, we use the constraint that: n_tilde_plus=0 , u_tilde_plus=0 as long as Gamma_tilde_minus<=1 (as long as there is no pair production) %
y(2)=0;
y(4)=0;
D_eqs_before_1st_pp(1)=y(2)-y(3)-1;
D_eqs_before_1st_pp(2)=0;
D_eqs_before_1st_pp(3)=( 1/(Gamma_thr^2*h_tilde_a) )*( y(3)./(y(5).^2.*Gamma_tilde_a(y(5))) ).*( -y(1)-s_tilde_1_a(y(5)) );
D_eqs_before_1st_pp(4)=0;
D_eqs_before_1st_pp(5)=(1/h_tilde_a)*(Gamma_tilde_a(y(5))./y(5)).*( -y(1)-s_tilde_1_a(y(5)) );
end
if x<0 % for s_tilde<0 where there are no initial electrons, we use the constraint that: n_tilde_minus=0 , u_tilde_minus=0 as long as Gamma_tilde_plus<=1 (as long as there is no pair production) %
y(3)=0;
y(5)=0;
D_eqs_before_1st_pp(1)=y(2)-y(3)-1;
D_eqs_before_1st_pp(2)=( 1/(Gamma_thr^2*h_tilde_a) )*( y(2)./(y(4).^2.*Gamma_tilde_a(y(4))) ).*( y(1)-s_tilde_1_a(y(4)) );
D_eqs_before_1st_pp(3)=0;
D_eqs_before_1st_pp(4)=(1/h_tilde_a)*(Gamma_tilde_a(y(4))./y(4)).*( y(1)-s_tilde_1_a(y(4)) );
D_eqs_before_1st_pp(5)=0;
end
end
function D_eqs_after_1st_pp=D_eqs_after_1st_pp(x,y) % a function that describe the diffrential equations for the solver function of matlab that solves the equations, with x=s , y=[E_tilde_par ; n_tilde_lab_plus ; n_tilde_lab_minus ; u_tilde_plus ; u_tilde_minus] , D_eqs=dy/dx %
D_eqs_after_1st_pp=zeros(5,1);
D_eqs_after_1st_pp(1)=y(2)-y(3)-1;
D_eqs_after_1st_pp(2)=y(2).*Gamma_tilde_a(y(4)).*q_tilde_a(y(2),y(2),y(3),y(4),y(5)).*(1./y(4))+( 1/(Gamma_thr^2*h_tilde_a) )*( y(2)./(y(4).^2.*Gamma_tilde_a(y(4))) ).*( y(1)-s_tilde_1_a(y(4))+q_tilde_1_a(y(2),y(2),y(3),y(4),y(5))-h_tilde_a*q_tilde_a(y(2),y(2),y(3),y(4),y(5)).*y(4) );
D_eqs_after_1st_pp(3)=y(3).*Gamma_tilde_a(y(5)).*q_tilde_a(y(3),y(2),y(3),y(4),y(5)).*(1./y(5))+( 1/(Gamma_thr^2*h_tilde_a) )*( y(3)./(y(5).^2.*Gamma_tilde_a(y(5))) ).*( -y(1)-s_tilde_1_a(y(5))+q_tilde_1_a(y(3),y(2),y(3),y(4),y(5))-h_tilde_a*q_tilde_a(y(3),y(2),y(3),y(4),y(5)).*y(5) );
D_eqs_after_1st_pp(4)=(1/h_tilde_a)*(Gamma_tilde_a(y(4))./y(4)).*( y(1)-s_tilde_1_a(y(4))+q_tilde_1_a(y(2),y(2),y(3),y(4),y(5))-h_tilde_a*q_tilde_a(y(2),y(2),y(3),y(4),y(5)).*y(4) );
D_eqs_after_1st_pp(5)=(1/h_tilde_a)*(Gamma_tilde_a(y(5))./y(5)).*( -y(1)-s_tilde_1_a(y(5))+q_tilde_1_a(y(3),y(2),y(3),y(4),y(5))-h_tilde_a*q_tilde_a(y(3),y(2),y(3),y(4),y(5)).*y(5) );
end
s_tilde_initial=0; % the value of s_tilde from which we start the solution. on this value of s_tilde we have the boundary conditions. this is the injection point. %
s_tilde_final=50; % the value we choose for the final s_tilde %
% the boundary conditions at s_tilde=s_tilde_initial %
E_tilde_par_max=(e*L_B*B)/(m_e*c^2); % the maximum value for E_tilde_par obtained form setting E_par=B %
%xi=10^-2; % a parameter for characterizing E_tilde_par_0 relative to E_tilde_par_max %
E_tilde_par_0=-xi*E_tilde_par_max; % this is E_tilde_par(s_tilde=s_tilde_initial) %
Gamma_tilde_plus_0=10/Gamma_thr; % the value we choose for Gamma_tilde_plus at s_tilde=0 %
Gamma_tilde_minus_0=10/Gamma_thr; % the value we choose for Gamma_tilde_minus at s_tilde=0 %
beta_tilde_plus_0=-(1-Gamma_thr^-2*Gamma_tilde_plus_0^-2)^(1/2); % the value for beta_tilde_plus at s_tilde=0 %
beta_tilde_minus_0=(1-Gamma_thr^-2*Gamma_tilde_minus_0^-2)^(1/2); % the value for beta_tilde_minus at s_tilde=0 %
u_tilde_plus_0=Gamma_tilde_plus_0*beta_tilde_plus_0; % the value for u_tilde_plus at s_tilde=0 %
u_tilde_minus_0=Gamma_tilde_minus_0*beta_tilde_minus_0; % the value for u_tilde_plus at s_tilde=0 %
N_tilde_0_plus=-10^-2; % The normalized particle flux at s_tilde=0 for the positrons %
N_tilde_0_minus=10^-2; % The normalized particle flux at s_tilde=0 for the electrons %
n_tilde_lab_plus_0=N_tilde_0_plus/beta_tilde_plus_0; % this is n_tilde_lab_plus(s_tilde=s_tilde_initial) %
n_tilde_lab_minus_0=N_tilde_0_minus/beta_tilde_minus_0; % this is n_tilde_lab_minus(s_tilde=s_tilde_initial) %
y_0=[E_tilde_par_0 , n_tilde_lab_plus_0 , n_tilde_lab_minus_0 , u_tilde_plus_0 , u_tilde_minus_0]; % putting all the initial conditions together as a vector for the solver %
s_tilde_sol_span_positive=[s_tilde_initial,s_tilde_final]; % solution range for s_tilde>0 %
s_tilde_sol_span_negative=[s_tilde_initial,(-s_tilde_final)]; % solution range for s_tilde<0 %
function [condition_1st_pp_for_positive_s_tilde,indicator_terminate_1st_pp_for_positive_s_tilde,direction_1st_pp_for_positive_s_tilde]=pair_production_1st_for_positive_s_tilde(x,y) % the event that specify for the ode solver when the 1st pair production occurs , applied for the electrons in the s_tilde>0 zone %
condition_1st_pp_for_positive_s_tilde=Gamma_tilde_a(y(5))-1; % when this value is zero, the pair production event occurs %
indicator_terminate_1st_pp_for_positive_s_tilde=1; % for this value the solver terminate when the event occurs %
direction_1st_pp_for_positive_s_tilde=1; % all zeros are to be located when the event function is increasing %
end
function [condition_1st_pp_for_negative_s_tilde,indicator_terminate_1st_pp_for_negative_s_tilde,direction_1st_pp_for_negative_s_tilde]=pair_production_1st_for_negative_s_tilde(x,y) % the event that specify for the ode solver when the 1st pair production occurs , applied for the positrons in the s_tilde<0 zone %
condition_1st_pp_for_negative_s_tilde=Gamma_tilde_a(y(4))-1; % when this value is zero, the pair production event occurs %
indicator_terminate_1st_pp_for_negative_s_tilde=1; % for this value the solver terminate when the event occurs %
direction_1st_pp_for_negative_s_tilde=1; % all zeros are to be located when the event function is increasing %
end
u_tilde_a_stop_tol=10^-9; % setting a tolerance for u_tilde_a from which below the particles will be considered to have reached a complete stop, triggering the termination of the code run (this is for preventing possible problems that might arise from not terminating the code run) %
function [condition_pp,indicator_terminate_pp,direction_pp]=pair_production_and_stopping_points(x,y) % the event that specify for the ode solver when pair production occurs , applied for both the positrons and electrons after the 1st pair production had already occured %
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]; % for the first two components of this vector : when this value is zero, the pair production event occurs , the last two component of this vector: checking for the stopping point of the positrons (which for them will occur in the s_tilde>0 zone) and the electrons (which for them will occur in the s_tilde<0 zone) %
indicator_terminate_pp=[0,0,1,1]; % 0 - the solver does not terminate when the event occurs , 1 - the solver does terminate when the event occurs %
direction_pp=[0,0,0,0]; % 0 - all zeros are to be located, regardless if the event function is increasing or decreasing , +1 - only for zeros where the event function is increasing , -1 - only for zeros where the event function is decreasing %
end
options_eqs_for_positive_s_tilde_1st_pp=odeset('Events',@pair_production_1st_for_positive_s_tilde,'Refine',20,'RelTol',10^-5,'AbsTol',10^-8); % special options for the ode solver , applied for the s_tilde>0 zone before the electrons cause the 1st pair production event %
options_eqs_for_negative_s_tilde_1st_pp=odeset('Events',@pair_production_1st_for_negative_s_tilde,'Refine',20,'RelTol',10^-5,'AbsTol',10^-8); % special options for the ode solver , applied for the s_tilde<0 zone before the positrons cause the 1st pair production event %
options_eqs_for_pps_after_1st_pp=odeset('Events',@pair_production_and_stopping_points,'Refine',20,'RelTol',10^-5,'AbsTol',10^-8); % special options for the ode solver , applied for both the positrons and electrons after the 1st pair production had already occured %
% solving the equations to get E_tilde_par(s_tilde) , n_tilde_lab_plus(s_tilde) , n_tilde_lab_minus(s_tilde) , u_tilde_plus(s_tilde) , u_tilde_minus(s_tilde) %
% obtaining the solution for s_tilde>0 %
[s_tilde_positive_before_1st_pp,y_solved_for_positive_s_tilde_before_1st_pp,s_tilde_positive_1st_pp,y_solved_for_positive_s_tilde_1st_pp,index_positive_1st_pp]=ode15s(@D_eqs_before_1st_pp,s_tilde_sol_span_positive,y_0,options_eqs_for_positive_s_tilde_1st_pp); % solving from s_tilde_initial=0 up to when Gamma_tilde_minus=1 (where the 1st pair production process occurs) %
numel(y_solved_for_positive_s_tilde_1st_pp) % trying to see if theres a problem here %
if numel(y_solved_for_positive_s_tilde_1st_pp)>0 % checking to see that the solver stopped at the event point in the s_tilde>0 zone %
s_tilde_sol_span_positive_after_1st_pp=[s_tilde_positive_1st_pp,s_tilde_final]; % solution range, from the point of the 1st pair prodution process up to s_tilde_final, at the s_tilde>0 zone %
y_solved_for_positive_s_tilde_1st_pp=[y_solved_for_positive_s_tilde_1st_pp(1) , y_solved_for_positive_s_tilde_1st_pp(2) , y_solved_for_positive_s_tilde_1st_pp(3) , y_solved_for_positive_s_tilde_1st_pp(5) , y_solved_for_positive_s_tilde_1st_pp(5)]; % at the point of the 1st pair production process in the s_tilde>0 zone, we assign the condition u_tilde_plus=u_tilde_minus %
[s_tilde_positive_after_1st_pp,y_solved_for_positive_s_tilde_after_1st_pp,s_tilde_positive_pps_after_1st_pp,y_solved_for_positive_s_tilde_pps_after_1st_pp,index_positive_pps_after_1st_pp]=ode15s(@D_eqs_after_1st_pp,s_tilde_sol_span_positive_after_1st_pp,y_solved_for_positive_s_tilde_1st_pp,options_eqs_for_pps_after_1st_pp); % solving from the point of the 1st pair prodution process up to s_tilde_final, at the s_tilde>0 zone %
end
% obtaining the solution for s_tilde<0 %
[s_tilde_negative_before_1st_pp,y_solved_for_negative_s_tilde_before_1st_pp,s_tilde_negative_1st_pp,y_solved_for_negative_s_tilde_1st_pp,index_negative_1st_pp]=ode15s(@D_eqs_before_1st_pp,s_tilde_sol_span_negative,y_0,options_eqs_for_negative_s_tilde_1st_pp); % solving from s_tilde_initial=0 up to when Gamma_tilde_plus=1 (where the 1st pair production process occurs) %
numel(y_solved_for_negative_s_tilde_1st_pp) % trying to see if theres a problem here %
if numel(y_solved_for_negative_s_tilde_1st_pp)>0 % checking to see that the solver stopped at the event point in the s_tilde<0 zone %
s_tilde_sol_span_negative_after_1st_pp=[s_tilde_negative_1st_pp,(-s_tilde_final)]; % solution range, from the point of pair prodution down to -s_tilde_final, at the s_tilde<0 zone %
y_solved_for_negative_s_tilde_1st_pp=[y_solved_for_negative_s_tilde_1st_pp(1) , y_solved_for_negative_s_tilde_1st_pp(2) , y_solved_for_negative_s_tilde_1st_pp(3) , y_solved_for_negative_s_tilde_1st_pp(4) , y_solved_for_negative_s_tilde_1st_pp(4)]; % at the point of the 1st pair production process in the s_tilde<0 zone, we assign the condition u_tilde_minus=u_tilde_plus %
[s_tilde_negative_after_1st_pp,y_solved_for_negative_s_tilde_after_1st_pp,s_tilde_negative_pps_after_1st_pp,y_solved_for_negative_s_tilde_pps_after_1st_pp,index_negative_pps_after_1st_pp]=ode15s(@D_eqs_after_1st_pp,s_tilde_sol_span_negative_after_1st_pp,y_solved_for_negative_s_tilde_1st_pp,options_eqs_for_pps_after_1st_pp); % solving from the point of the 1st pair prodution process down to -s_tilde_final, at the s_tilde<0 zone %
end
if numel(y_solved_for_positive_s_tilde_1st_pp)>0 % checking to see that the solver stopped at the event point in the s_tilde>0 zone %
s_tilde_positive=[s_tilde_positive_before_1st_pp ; s_tilde_positive_after_1st_pp]; % mending the solution for before and after the 1st pair production event, at the s_tilde>0 zone %
y_solved_for_positive_s_tilde=[y_solved_for_positive_s_tilde_before_1st_pp ; y_solved_for_positive_s_tilde_after_1st_pp];
else
s_tilde_positive=s_tilde_positive_before_1st_pp;
y_solved_for_positive_s_tilde=y_solved_for_positive_s_tilde_before_1st_pp;
end
if numel(y_solved_for_negative_s_tilde_1st_pp)>0 % checking to see that the solver stopped at the event point in the s_tilde<0 zone %
s_tilde_negative=[s_tilde_negative_before_1st_pp ; s_tilde_negative_after_1st_pp]; % mending the solution for before and after the 1st pair production event, at the s_tilde<0 zone %
y_solved_for_negative_s_tilde=[y_solved_for_negative_s_tilde_before_1st_pp ; y_solved_for_negative_s_tilde_after_1st_pp];
else
s_tilde_negative=s_tilde_negative_before_1st_pp;
y_solved_for_negative_s_tilde=y_solved_for_negative_s_tilde_before_1st_pp;
end
% mending the solution for s_tilde>0 and s_tilde<0 : getting the values for E_tilde_par(s_tilde) , n_tilde_lab_plus(s_tilde) , n_tilde_lab_minus(s_tilde) , u_tilde_plus(s_tilde) , u_tilde_minus(s_tilde) made up from the solution in s_tilde>0 and in s_tilde<0 , while also not taking the values at s_tilde=0 twice %
s_tilde=[ flipud(s_tilde_negative(2:length(s_tilde_negative))) ; s_tilde_positive ];
E_tilde_par=[ flipud( y_solved_for_negative_s_tilde(2:length(y_solved_for_negative_s_tilde(:,1)),1) ) ; y_solved_for_positive_s_tilde(:,1) ];
n_tilde_lab_plus=[ flipud( y_solved_for_negative_s_tilde(2:length(y_solved_for_negative_s_tilde(:,2)),2) ) ; y_solved_for_positive_s_tilde(:,2) ];
n_tilde_lab_minus=[ flipud( y_solved_for_negative_s_tilde(2:length(y_solved_for_negative_s_tilde(:,3)),3) ) ; y_solved_for_positive_s_tilde(:,3) ];
u_tilde_plus=[ flipud( y_solved_for_negative_s_tilde(2:length(y_solved_for_negative_s_tilde(:,4)),4) ) ; y_solved_for_positive_s_tilde(:,4) ];
u_tilde_minus=[ flipud( y_solved_for_negative_s_tilde(2:length(y_solved_for_negative_s_tilde(:,5)),5) ) ; y_solved_for_positive_s_tilde(:,5) ];
John BG
John BG le 20 Fév 2016
If you don't supply THE code that brought you to the error you are seeking help for, the readers cannot reproduce the problem. In the script you supplied,
1.- You are defining functions with function names exactly the same as the output variables of such functions. Do you really expect such habit to have your script, or any script, working without errors?
2.- The code you supplied give basic syntax errors. removed some of them, gave up 15min later.
3.- The following are variables NOT defined in the supplied script:
h_tilde_a=Gamma_thr
u_tilde_a=Gamma_thr
n_tilde_lab_a=Gamma_thr
n_tilde_lab_plus=Gamma_thr
u_tilde_plus= Gamma_thr
n_tilde_lab_minus= Gamma_thr
in an attempt to have the supplied script reaching the error originating this question I gave the undefined variables the above errors, no way through the syntax errors.
4.- Something as basic as the variable x, not defined I did x=xi, and at this point is a good moment to ask, noch mal:
please hang the code that produces the error originating this question, not a chunk of it, not an earlier version that produces earlier errors, not the code without variables ..
5.- Would it be possible to make the script available as attached file instead?
And for the record: MATLAB CENTRAL readers, or for the case, any reader of any document, ever, tend to give up reading when either
1.- do not want to read further: not interested, boring, already know, something better to read
2.- find it difficult to read further.
my guess your question falls in case 2.
Regards
John

Connectez-vous pour commenter.

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by