ODE45 error, "inputs must be scalar and square"

2 vues (au cours des 30 derniers jours)
Melody
Melody le 4 Mar 2014
Commenté : Star Strider le 4 Mar 2014
Running my code is giving me this error:
"??? Error using ==> mpower Inputs must be a scalar and a square matrix.
Error in ==> marchup at 11 Mu=(Mi/(1-Mi^2))*(-((1+(((gam-1)/2)*Mi))/A)*dA+((2*gam*(Mi^2)*((1+((...
Error in ==> odearguments at 110 f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ==> ode45 at 173 [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in ==> combflow at 66 [Xu, Mu]=ode45(@marchup,[xs,0],[1, Mi], f);"
Here's the ODE function:
function Mu=marchup(X, Mi, f)
Dt=5/100;
gam=1.4;
L=2;
D=2*Dt*(1+.5*cos((pi/L)*X));
A=(pi/4)*D^2;
dD=-(pi/L)*Dt*sin((pi/L)*X);
dA=(pi/4)*dD^2;
Mu=(Mi/(1-Mi^2))*(-((1+(((gam-1)/2)*Mi))/A)*dA+((2*gam*(Mi^2)*((1+((... (gam-1)/2)*Mi^2)*f)/D))));
end
How I'm calling it:
Mi=1-Bp*(xs-x(j-1));
[Xu, Mu]=ode45(@marchup,[xs,0],[1, Mi], f);
Where xs is the sonic point in a flow and x(j-1) is the point just before that.
  1 commentaire
Star Strider
Star Strider le 4 Mar 2014
You probably need to vectorize your expression for Mu.

Connectez-vous pour commenter.

Réponses (1)

Melody
Melody le 4 Mar 2014
I thought I tried that, must not have. Thanks for the help!
  1 commentaire
Star Strider
Star Strider le 4 Mar 2014
My pleasure!
I probably should have put that as an answer!

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by