-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test_alpha25_unstable.m
189 lines (180 loc) · 6.67 KB
/
Test_alpha25_unstable.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
%% simulation part
% data
alpha=25;
phi0 = pi;
yes_animate = 0;
yesplot = 1;
MaxStep = 0.1;
maxTime =400;
g=980;
Rg = 1;
Rh = 7.412625;
M = 15.64;
Rw=0.5;
a=Rw;
b=Rw;
% graph
f_list=[];
z_list=[];
z_ulist=[];
f_defined=[];
f_udefined=[];
%normal_force_list=[];
% calculate
c=Rw/tand(alpha);
%for loop for f
for f=1:0.001:10
w=2*pi*f;
phidot0= w;
%for loop for z
for z=-10:0.01:0
Rb=sqrt(Rw^2+(Rw^2*z^2)/c^2);
% N=solve_hulahoop_normalForce(phi0,phidot0,w,Rg,Rh,Rb,M,maxTime);
% normal_force=N(:,1);
normal_force=abs(-M*w^2*(Rh+Rg-Rb));
% disp([num2str(normal_force)])
% normal_force(end+1)=normal_force;
Fx=(2*Rb)/(Rw^2);
Fy=0;
Fz=((-2)*z)/(c^2);
z_intersect=(Fx*Rb)/Fz+z;
if z_intersect>=0
angle=atand(Rb/(z_intersect+abs(z)));
end
if z_intersect<0
angle=atand(Rb/(abs(z)-abs(z_intersect)));
end
vertical_force=normal_force*sind(angle);
%find next vertical force
z_next=z+0.1;
Rb_next=sqrt(Rw^2+(Rw^2*(z_next)^2)/c^2);
% N_next=solve_hulahoop_normalForce(phi0,phidot0,w,Rg,Rh,Rb_next,M,maxTime);
% normal_force_next=N_next(:,1);
normal_force_next=abs(-M*w^2*(Rh+Rg-Rb_next));
Fx_next=(2*Rb_next)/(Rw^2);
Fy_next=0;
Fz_next=((-2)*z_next)/(c^2);
z_intersect_next=(Fx_next*Rb_next)/Fz_next+z_next;
if z_intersect_next>=0
angle_next=atand(Rb_next/(z_intersect_next+abs(z_next)));
end
if z_intersect_next<0
angle_next=atand(Rb_next/(abs(z_next)-abs(z_intersect_next)));
end
vertical_force_next=normal_force_next*sind(angle_next);
%find previous vertical force
z_previous=z-0.1;
Rb_previous=sqrt(Rw^2+(Rw^2*(z_previous)^2)/c^2);
% N_previous=solve_hulahoop_normalForce(phi0,phidot0,w,Rg,Rh,Rb_previous,M,maxTime);
% normal_force_previous=N_previous(:,1);
normal_force_previous=abs(-M*w^2*(Rh+Rg-Rb_previous));
Fx_previous=(2*Rb_previous)/(Rw^2);
Fy_previous=0;
Fz_previous=((-2)*z_previous)/(c^2);
z_intersect_previous=(Fx_previous*Rb_previous)/Fz_previous+z_previous;
if z_intersect_previous>=0
angle_previous=atand(Rb_previous/(z_intersect_previous+abs(z_previous)));
end
if z_intersect_previous<0
angle_previous=atand(Rb_previous/(abs(z_previous)-abs(z_intersect_previous)));
end
vertical_force_previous=normal_force_previous*sind(angle_previous);
%check if this is an equilibrium pt
if abs(vertical_force-M*g)<=3000
%check stable
if vertical_force_next<M*g && vertical_force_previous>M*g
if length(f_defined)==0
f_defined(end+1)=f;
z_list(end+1)=z;
end
if f_defined(end)==f
z_compare=z_list(end);
Rb_compare=sqrt(Rw^2+(Rw^2*(z_compare)^2)/c^2);
% N_compare=solve_hulahoop_normalForce(phi0,phidot0,w,Rg,Rh,Rb_compare,M,maxTime);
% normal_force_compare=N_compare(:,1);
normal_force_compare=abs(-M*w^2*(Rh+Rg-Rb_compare));
Fx_compare=(2*Rb_compare)/(Rw^2);
Fy_compare=0;
Fz_compare=((-2)*z_compare)/(c^2);
z_intersect_compare=(Fx_compare*Rb_compare)/Fz_compare+z_compare;
if z_intersect_compare>=0
angle_compare=atand(Rb_compare/(z_intersect_compare+abs(z_compare)));
end
if z_intersect_compare<0
angle_compare=atand(Rb_compare/(abs(z_compare)-abs(z_intersect_compare)));
end
vertical_force_compare=normal_force_compare*sind(angle_compare);
if abs(vertical_force-M*g)<abs(vertical_force_compare-M*g)
z_list(end)=z;
end
end
if f_defined(end)~=f
f_defined(end+1)=f;
z_list(end+1)=z;
end
end
%check unstable
if vertical_force_next>=M*g && vertical_force_previous<=M*g
if length(f_udefined)==0
f_udefined(end+1)=f;
z_ulist(end+1)=z;
end
if f_udefined(end)==f
z_compare=z_ulist(end);
Rb_compare=sqrt(Rw^2+(Rw^2*(z_compare)^2)/c^2);
% N_compare=solve_hulahoop_normalForce(phi0,phidot0,w,Rg,Rh,Rb_compare,M,maxTime);
% normal_force_compare=N_compare(:,1);
normal_force_compare=abs(-M*w^2*(Rh+Rg-Rb_compare));
Fx_compare=(2*Rb_compare)/(Rw^2);
Fy_compare=0;
Fz_compare=((-2)*z_compare)/(c^2);
z_intersect_compare=(Fx_compare*Rb_compare)/Fz_compare+z_compare;
if z_intersect_compare>=0
angle_compare=atand(Rb_compare/(z_intersect_compare+abs(z_compare)));
end
if z_intersect_compare<0
angle_compare=atand(Rb_compare/(abs(z_compare)-abs(z_intersect_compare)));
end
vertical_force_compare=normal_force_compare*sind(angle_compare);
if abs(vertical_force-M*g)<abs(vertical_force_compare-M*g)
z_ulist(end)=z;
end
end
if f_udefined(end)~=f
f_udefined(end+1)=f;
z_ulist(end+1)=z;
end
end
end
end
end
%% plot part
%normal_force_list
% simulation
plot_list=[];
for f=1:0.1:10
f_list(end+1)=f;
plot_list(end+1)=0;
end
% z_list
z_ulist
plot(f_defined,z_list,'m');
hold on
plot(f_udefined,z_ulist,'--');
hold on
plot(f_list,plot_list,'k');
hold on
%% experiment part
f_test=[8.92,9.04, 8.49,8.52, 8.01,8.08, 7.49,7.57, 6.97,7.03, 6.52,6.58, 5.98,6.04, 5.48,5.52, 4.98,5.07, 4.49,4.53, 4.02,4.08, 3.523,3.539];
z_test=[-0.1,-0.3, 0,-0.2, -0.1,-0.3, -0.1,-0.2, -0.1,-0.25, -0.1,-0.2, -0.2,-0.4, -0.25,-0.4, -0.3,-0.4, -0.45,-0.6, -0.45,-0.8, -1.1,-1.4];
for time=1:1:12
% disp(num2str(f_test(2*time)));
% x=[f_test(2*time-1),f_test(2*time)]
% y=[z_test(2*time-1),z_test(2*time)]
% disp(num2str(f_test(2*time-1)));
rectangle('Position',[f_test(2*time-1) z_test(2*time) abs(f_test(2*time)-f_test(2*time-1)) abs(z_test(2*time-1)-z_test(2*time))]);
axis([0 10 -10 0]);
end
hold on
xlabel("f (alpha = 25)");
ylabel("equilibrium point");