dimensionality problem with differential equations

1 次查看(过去 30 天)
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

采纳的回答

Andrei Bobrov
Andrei Bobrov 2011-4-26
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by