Error: "Difference order N must be a positive integer scalar"

In fact, I am trying to gather the data in a matrix. But I keep receiving the error "Difference order N must be a positive integer scalar" when I use the "for" loop. Otherwise, it works for every m value. Here's the code I am working on below:
syms y(t) Y t
%parameters
ed=0.001;
Ev=1000;
n=4000;
A=zeros(41,10);
ed=0.001;
for m=1:10
eq = diff(y,t) == (1/m)*(((Ev*(ed*t-y))/n)^m);
[VF,Subs] = odeToVectorField(eq);
DE = matlabFunction(VF, 'Vars',{t,Y});
[t,y] = ode45(DE, [0 10], 0);
A(:,m)=y;
end

3 comentarios

What do expect the code ..diff(y,t).. to do?
(fixed the editing for you ...)
is there an alternative?
is there an alternative?
To what? To your diff(y, t)? Maybe. If only we knew what you meant to do with that.

Iniciar sesión para comentar.

 Respuesta aceptada

[t,y] = ode45(DE, [0 10], 0);
After the first iteration through your for loop, y is no longer a symbolic function. It was overwritten with a double array by this line. Consider changing the second output of your ode45 call to something like ysol.

1 comentario

MOHAMED AMINE BEN TALEB
MOHAMED AMINE BEN TALEB el 7 de Ag. de 2018
Editada: MOHAMED AMINE BEN TALEB el 7 de Ag. de 2018
Thank you Steven. I changed the two output t by "temp" and y by "ysol" as you had suggested. And it's actually working.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Productos

Versión

R2016a

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by