Info

This question is closed. Reopen it to edit or answer.

I am facing the problem on ode 45. any one knows help me?

1 view (last 30 days)
Warning: Failure at t=1.555351e-02. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (2.775558e-17) at time t.

Answers (1)

Walter Roberson
Walter Roberson on 11 Mar 2016
You have a singularity at time 1.555351e-02
  7 Comments
Walter Roberson
Walter Roberson on 14 Mar 2016
near line 39, your frewy6 code tries to display t and x, but they are not defined until the line after that.
Walter Roberson
Walter Roberson on 14 Mar 2016
Near that t, x(17) starts to become notably larger and positive, and x(18) starts to become even more notably larger negative.
Look at your code near line 107. You write your 6 x 6 d (inertia) terms into x(i,j) . But x is a 24 x 1 input, so writing into x(i,j) results in a 24 x 6 array with the upper 6 x 6 being the values of d and the left edge otherwise being the input x, and the lower right being all 0 (because of automatic 0 extension when you create additional columns.)
And then after that, you never refer to x with two subscripts, continuing to refer to it with one subscript, and you never (that I found) refer to it with a subscript greater than 24, so you never reach into that second column. You do, however, use the updated x(1:6), and you write the d into separate variables like d15 and use those: if you are intentionally writing over parts of x, why not leave x alone and refer to those d variables instead??
Later you have loops such as
c5=0;
for i=5
for j=1:6
for k=1:6
% printf('d(i,j)=%d \t \n',d(i,j));
c5=c5+(c(i,j,k));
end
end
end
as a matter of efficiency and clarity, why not use something like
VEC = @(V) V(:);
c5 = sum(VEC(c(5,:,:)));
(The VEC would only be done once in the code and called upon after that.)
Equivalents:
c5 = sum(reshape(c(5,:,:),[],1));
or
c5 = sum(sum(c(5,:,:),3));

Community Treasure Hunt

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

Start Hunting!