h_fig3 = [];
origY3={};
figure(3);
b = get(gca, 'children');
figure(1);
axis([-0.04 0.08 0 0.06]);
hold on;
for i = 1:length(b)
xx = get(b(i), 'xdata');
yy = get(b(i), 'ydata');
x_new=xx/50 + 0.005;
y_new=yy/50+0.0;
h_line = line(x_new, y_new);
h_fig3 = [h_fig3, h_line];
origY3{i}=y_new;
end
figure(4);
b = get(gca, 'children');
figure(1);
axis([-0.04 0.08 0 0.06]);
hold on;
h_fig4 = [];
orig_x4 = {};
orig_y4 = {};
for i = 1:length(b)
xx = get(b(i), 'xdata');
yy = get(b(i), 'ydata');
x_trans = xx/50 + 0.04;
y_trans = yy/50 ;
h_line = line(x_trans, y_trans,'color',[1 0 1]);
h_fig4 = [h_fig4, h_line];
orig_x4{i} = x_trans;
orig_y4{i} = y_trans;
end
all_x = cell2mat(orig_x4);
all_y = cell2mat(orig_y4);
cx = mean([min(all_x), max(all_x)]);
cy = mean([min(all_y), max(all_y)]);
h = line([-0.04 0.04], [0.04 0.04]);
y1 = linspace(0, 0.04);
x1 = 0.002 * sin(800 * y1);
h1 = line(x1, y1);
y2 = linspace(0, 0.025);
x2 = -0.03 + 0.002 * sin(800 * y2);
h2 = line(x2, y2);
F=@(x) 50000*x+410000*(x-0.024).*(x>0.024);
t_ax=linspace(0,0.025);dt=t_ax(2)-t_ax(1);
z=zeros(1,100);
z(1)=0;z(2)=4*dt;
for ii=2:99
z(ii+1)=2*z(ii)-z(ii-1)-F(z(ii))/5*dt*dt;
end
a=[z(3:100)+z(1:98)-2*z(2:99)]/dt^2;
ax2=axes('pos',[0.2 0.7 0.5 0.35]);hold(ax2,'on');
while true
xa_save=[];ya_save=[];
for i = 1:100
ai = z(i);
set(h, 'YData', [0.04 0.04] - ai);
new_height1 = 0.04 - ai;
if new_height1 > 0.005
set(h1, 'YData', y1 * new_height1 / 0.04);
end
current_bar_height = 0.04 - ai;
if current_bar_height <= 0.025
new_height2 = current_bar_height;
if new_height2 > 0.005
set(h2, 'YData', y2 * new_height2 / 0.025);
end
else
set(h2, 'YData', y2);
end
for k = 1:length(h_fig3)
baseY = origY3{k};
newY = baseY - ai;
set(h_fig3(k),'YData',newY);
end
theta