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
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!