dimensionality problem with differential equations

4 ビュー (過去 30 日間)
Ruben
Ruben 2011 年 4 月 26 日
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 Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by