I'm working on a small simulation in matlab. For this purposes I want to create an animation of the simulated object (inverted pendulum). Unfortunatly the axes keep rescaling.
I tried everything. There are similar questions, but I just can't get it to work. The best i got is the code below. Where I get both axes at the same time, the scaled from -5 to 5 and those scaled by matlab.
%init visualisation
visualisation = figure();
axis([-5 5 -5 5]);
xlim([-5 5]);
ylim([-5 5]);
ax_hand = axes;
for i = 1:N
k1 = h * feval ( 'RHS', t0, x0, u );
k2 = h * feval ( 'RHS', t0 + (h/2), x0 + (k1/2), u);
k3 = h * feval ( 'RHS', t0 + h/2, x0 + k2/2, u);
k4 = h * feval ( 'RHS', t0 + h, x0 + k3, u);
x0 = x0 + ( k1 + 2*k2 + 2*k3 + k4 ) / 6;
t0 = t0 + h;
% model output
wi(1:neqn,i+1) = x0';
% model visualisation
%plotting cart
figure(visualisation);
plot(x0(3), 0, 'ro', 'LineWidth', 3);
%plotting pendulum
l = 2;
%plot(sin(x0(1))*l, cos(x0(1))*l, 'b*' , 'LineWidth', 2);
% regulator
end;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…