dimensionality problem with differential equations

4 visualizaciones (últimos 30 días)
Ruben
Ruben el 26 de Abr. de 2011
Hello,
when trying to solve a set of 2 differential equations, matlab gives me the following error:
??? In an assignment A(I) = B, the number of elements in B and I must be the same.
the code is as follows:
tspan = [0 tijd];
initialvalues = [0; 0];
[X,Y] = ode45(@dvgl,tspan,initialvalues);
with dvgl.m as follows:
k = 12.6651;
I2 = 0.516e-2;
dy = zeros(2,1);
dy(1) = y(2); % y(1) = theta2
dy(2) = 1./I2*((omega1./y(2)).*T1-k.*y(1)); % y(2) = omega2
omega1 is a 1 by 1667 vector. All te rest are scalars
Your help would be much appreciated.
Sincere regards,
Ruben

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 26 de Abr. de 2011
variant
I'm sorry I made a T1 variable: t = T1
dvgl = @(t,y,omega,k,I2)[y(2); 1./I2*((omega1./y(2)).*t-k.*y(1))];
k = 12.6651;
I2 = 0.516e-2;
tspan = [0 tijd];
initialvalues = [0; 0];
XY = cell(length(omega),2);
for j = 1:length(omega)
[XY{j,1},XY{j,2}] = ode45(@(t,y)dvgl(t,y,omega(j),k,I2),tspan,initialvalues);
end

Más respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by