Hi everyone im trying to solve a system of coupled ordinary differential equations using ODE45 and i keep getting this error: Error using odearguments (line 90) GSM_N must return a column vector. Error in ode23 (line 112) [neq, tspan, ntspan, next,

i put my code below for you guys to help me find my error thanks
function dy = gsm_n(t,y)
global D l rho k1 n1 nn Mn Jm Ui Ra Re La Oh a b p x
m= rho*pi*((D*D)/4)*l; %Berechnung der Masse
Jg= 0.5*m*((D*D)/4); %Berechnung der Massenträgheitsmoment der GSM
phi= Ui./(k1*n1); %Berechnung der Fluss
dy1 = ((((n1-y(1))/(n1-nn))*Mn)-((k1*phi*y(2))/(2*pi)))/(2*pi*(Jg+Jm)); %mit y(1)= dndt
PHI= -a*cos(x)+b*(2*x-20);
We= 952*p; %gesamterregerwindungszahl
dy2= ((k1*phi*y(1))-((Ra+Re)*y(2)))./(La+((1+Oh)*We*PHI)); %mit y(2)= dIedt
dy = [dy1;dy2];
and then i run this in a main like this:
global D p l rho k1 n1 Ra Re La x Oh a b nn Mn Jm Ui %definition von global Variable
D= 0.158;
p=2;
l=0.25;
rho=2700;
k1= 720;
n1=50;
Ra= 0.198;
Re= 115;
La= 0.0042;
Oh=0.1;
a= -0.01792;
b= 0.0002088;
x= (0:0.07:1.3);
nn= 48.8167;
Mn= 24;
Jm= 0.024;
Ui=[4.8 105 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440];
t = [0 10];
Y0= [50 0];
[T,Y] = ode23(@gsm_n, t, Y0);
plot(T,Y(:,1),'r',T,Y(:,2),'b');

 Accepted Answer

dy1 and dy2 should both be scalar values.
In your case, they are not since phi is a vector.
Best wishes
Torsten.

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!