Error using odearguments line doesn't exist.
1 view (last 30 days)
Show older comments
[T,Y] = ode45(@Bqfun1,[0 2],[1 1 -0.01]);
plot (T,Y(:,1),'b','linewidth',1)
function dy1 = Bqfun1(t,y)
dy1 = zeros(2,1);
dy1=[y(2)];
y(3)
-3*y(3)-3*y(2)-y(1)-4*sin(t);
end
Error using odearguments (line 95)
BQFUN1 returns a vector of length 1, but the length of initial conditions vector is 3. The vector returned by BQFUN1 and
the initial conditions vector must have the same number of elements.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in Test4 (line 1)
[T,Y] = ode45(@Bqfun1,[0 2],[1 1 -0.01]);
What the heck does this even mean? I dont have a line 95.
0 Comments
Answers (1)
Walter Roberson
on 8 May 2021
[T,Y] = ode45(@Bqfun1,[0 2],[1 1 -0.01]);
That passes in three boundary conditions.
dy1 = zeros(2,1);
That hints you are expecting to output two boundary values
dy1=[y(2)];
But then you overwrite the variable with a scalar
y(3)
and display the third boundary condition
-3*y(3)-3*y(2)-y(1)-4*sin(t);
and calculate something and throw away the result of the calculation.
I would suggest that you misplaced the ]
2 Comments
Walter Roberson
on 8 May 2021
I said you misplaced the ] not that you should not have it.
[T,Y] = ode45(@Bqfun1,[0 2],[1 1 -0.01]);
plot (T,Y(:,1),'b','linewidth',1)
function dy1 = Bqfun1(t,y)
dy1 = zeros(2,1);
dy1=[y(2);
y(3)
-3*y(3)-3*y(2)-y(1)-4*sin(t)];
end
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!