-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplotStabilities.m
More file actions
65 lines (55 loc) · 1.89 KB
/
plotStabilities.m
File metadata and controls
65 lines (55 loc) · 1.89 KB
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
%Generates gif of joint stability vector field and joint flow from 4
%initial conditions over varying stiffnesses
%Remember to initialize sysplotter and have gif Add-On installed
ks = [0:.001/3:.075];
dt = 1/30;
%Declare salp characteristic values
salp = struct();
%Length of individual zooid units
salp.L = .25;
%Ratio of Y drag to X drag of a link - Y drag probably higher
salp.dragRatio = 3;
%Initialize figure and figure size
fig2 = figure(2);
fig2.Position = [97 145 1648 518];
set(gcf,'color','w');
%For each stiffness we want to visualize
for stiffness_index = 1:numel(ks)
%Set salp stiffness
salp.jointStiffness = ks(stiffness_index);
%Set initial joint conditions using intermediate polar coordinates
mag = pi/2;
thetas = [pi/4,3*pi/4,5*pi/4,7*pi/4];
startPoints = zeros(numel(thetas),2);
for i = 1:numel(thetas)
startPoints(i,:) = [mag*cos(thetas(i)),mag*sin(thetas(i))];
end
%Grab the plot data
results = makeStabilityDiagram(salp,startPoints);
clf;
tcl = tiledlayout(1,3);
%Plot each stability vector field and the four joint flows
for i = 1:3
nexttile;
quiver(results{i}.R1,results{i}.R2,results{i}.dR1,results{i}.dR2);
hold on;
for j = 1:size(results{i}.pathx,1)
plot(results{i}.pathx(j,:),results{i}.pathy(j,:),'LineWidth',2);
end
axis square
xticks([-pi,0,pi]);
yticks([-pi,0,pi]);
xticklabels({'-\pi','0','\pi'});
yticklabels({'-\pi','0','\pi'});
title(['Link ',num2str(i),' Firing']);
xlabel('Tail Joint');
ylabel('Head Joint');
end
title(tcl,{['Stiffness: ',num2str(round(salp.jointStiffness,3))],''});
drawnow;
if stiffness_index == 1
gif('Stability vs Stiffness.gif','DelayTime',dt);
else
gif;
end
end