MATLAB Answers

Interp1-Input coordinates must be real.

4 views (last 30 days)
Ece Kurt
Ece Kurt on 24 Nov 2020
Answered: Bjorn Gustavsson on 24 Nov 2020
Matlab gives this error. SOC_ent and DUdt is both array with constant terms and theta_n is changing. But non of the terms are complex it gives must be real error.
dudT= interp1(SOC_ent,dUdt,theta_n,'linear','extrap');
Error using matlab.internal.math.interp1
Input coordinates must be real.
Error in interp1 (line 154)
VqLite = matlab.internal.math.interp1(X,V,method,method,Xqcol);
Error in ode_spmet_degr_cycle (line 85)
dudT= interp1(SOC_ent,dUdt,theta_n,'linear');
Error in spmet>@(t,x)ode_spmet_degr_cycle(t,x,data,p,dUdt,SOC_ent) (line 43)
[ts,x] = ode23s(@(t,x) ode_spmet_degr_cycle(t,x,data,p,dUdt,SOC_ent),t,x0,Opt1);
Error in ode23s (line 362)
f1 = feval(odeFcn, t + 0.5*h, y + 0.5*h*k1, odeArgs{:});
Error in spmet (line 43)
[ts,x] = ode23s(@(t,x) ode_spmet_degr_cycle(t,x,data,p,dUdt,SOC_ent),t,x0,Opt1);
Error in Untitled (line 51)
[c_p,c_n,eps,delta_sei,V,R_tot_n,theta_n,c_ss_n,c_ss_p,T1,dudT,theta_p]= spmet(p,t,I,Uni,Upi,deltasei0,eps0,Ti);

  0 Comments

Sign in to comment.

Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson on 24 Nov 2020
Then it must be because your theta_n has become complex. How that came to be is impossible to guess based on this information. If you use the debugger you can step up into your ODE-function and inspect its state when the error happens. A blind guess is that you have some terms (with something like square roots or logs) that should be positive but has become negative. Perhaps you can avoid this by setting the ode-options for nonnegative solutions, perhaps you have to make bigger changes to the ODE.
HTH

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!