dimensionality problem with differential equations
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Andrei Bobrov
on 26 Apr 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
0 Comments
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!