-
Notifications
You must be signed in to change notification settings - Fork 3
/
SDOF_PlotFRF.m
executable file
·163 lines (133 loc) · 4.54 KB
/
SDOF_PlotFRF.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
function SDOF_PlotFRF(r_vec,H_func,zeta_vec, ...
r_label,zeta_subtitle,H_subtitle,DispMagLines,r_peaks,H_mag_peaks,r_special,maxPhaseLag) %Optional arguments
if nargin<4
r_label='$r\equiv\frac{\omega}{\omega_{\mathrm{n}}}$';
else
if isempty(r_label)
r_label='$r\equiv\frac{\omega}{\omega_{\mathrm{n}}}$';
end
end
if nargin<5
zeta_subtitle='\zeta';
else
if isempty(zeta_subtitle)
zeta_subtitle='\zeta';
end
end
if nargin<6
H_subtitle='H';
else
if isempty(H_subtitle)
H_subtitle='H';
end
end
if nargin<7
DispMagLines=false;
else
if isempty(DispMagLines)
DispMagLines=false;
end
end
if nargin<11
maxPhaseLag=[];
end
set(groot,'DefaultAxesColorOrder',[0,0,1;0,0,0;1,0,0;0,0.5,0;1,0,1])
set(groot,'DefaultAxesLineStyleOrder','-|--|-.')
set(groot,'DefaultLineMarkerSize',5);
set(groot,'DefaultLineLineWidth',1);
%Identify and fix the maximum axes limits
zeta_temp=min(zeta_vec(zeta_vec>0));
H_temp_vec=H_func(r_vec,zeta_temp);
Fig_Nyq=figure;
plot_FRF_Nyq(H_temp_vec);
ax_Lims_Nyq=axis;clf;
axis(ax_Lims_Nyq);hold on
real_ticks=get(cla,'XTick');
imag_ticks=get(cla,'YTick');
Fig_3D=figure;
plot_FRF_3d(r_vec,H_temp_vec);
clf;
ylim(ax_Lims_Nyq(1:2));
set(cla,'YTick',real_ticks);
zlim(ax_Lims_Nyq(3:4));
set(cla,'ZTick',imag_ticks);
hold on
Fig_r_i=figure;
ax_r=subplot(2,1,1);
ylim(ax_Lims_Nyq(1:2));
set(ax_r,'YTick',real_ticks);
hold on
ax_i=subplot(2,1,2);
ylim(ax_Lims_Nyq(3:4));
set(ax_i,'YTick',imag_ticks);
hold on
Fig_Bode1=figure;
[ax_mag1]=plot_FRF_mag_phase(r_vec,H_temp_vec,[],[],[],[],[],[],maxPhaseLag);
v=axis(ax_mag1);
clf;
ax_mag1=subplot(4,1,[1:3]);hold on
ylim(ax_mag1,v(3:4));
ax_phase1=subplot(4,1,4);hold on
Fig_Bode2=figure;
ax_mag2=subplot(4,1,[1:3]);hold on
ax_phase2=subplot(4,1,4);hold on
Fig_Bode3=figure;
ax_mag3=subplot(4,1,[1:3]);hold on
ax_phase3=subplot(4,1,4);hold on
legend_str=strings(length(zeta_vec),1);
for ii=1:length(zeta_vec)
H_vec=H_func(r_vec,zeta_vec(ii));
H_temp_vec=H_vec;
if zeta_vec(ii)==0
H_temp_vec(real(H_vec)<ax_Lims_Nyq(1))=nan+1i*nan;
H_temp_vec(real(H_vec)>ax_Lims_Nyq(2))=nan+1i*nan;
H_temp_vec(imag(H_vec)<ax_Lims_Nyq(3))=nan+1i*nan;
H_temp_vec(imag(H_vec)>ax_Lims_Nyq(4))=nan+1i*nan;
end
figure(Fig_3D)
plot_FRF_3d(r_vec,H_temp_vec,r_label,H_subtitle,1,DispMagLines);
plot_FRF_r_i(r_vec,H_temp_vec,ax_r,ax_i,r_label,H_subtitle);
figure(Fig_Nyq)
plot_FRF_Nyq(H_temp_vec,r_label,H_subtitle);
plot_FRF_mag_phase(r_vec,H_vec,true,ax_mag1,ax_phase1,r_label,H_subtitle,DispMagLines,maxPhaseLag);
plot_FRF_mag_phase(r_vec,H_vec,false,ax_mag2,ax_phase2,r_label,H_subtitle,DispMagLines,maxPhaseLag);
plot_FRF_mag_phase(r_vec,H_vec,[false,false],ax_mag3,ax_phase3,r_label,H_subtitle,DispMagLines,maxPhaseLag);
if zeta_vec(ii)==0
legend_str(ii)="$"+zeta_subtitle+'=0;\;\mathrm{misleading}$';
elseif zeta_vec(ii)==1/sqrt(2)
legend_str(ii)="$"+zeta_subtitle+'=1/\sqrt{2}$';
elseif zeta_vec(ii)==sqrt(2)
legend_str(ii)="$"+zeta_subtitle+'=\sqrt{2}$';
else
legend_str(ii)="$"+zeta_subtitle+'='+zeta_vec(ii)+'$';
end
end
%Peaks curve
if nargin>8 && ~isempty(r_peaks)
H_mag_peaks(r_peaks>max(r_vec))=nan;
%r_peaks(r_peaks>max(r_vec))=nan;
plot(ax_mag1,r_peaks,H_mag_peaks,'-k','LineWidth',.5);
end
if nargin>9
if ~isempty(r_special)
xticks=get(ax_mag1,'XTick');
set(ax_mag1,'XTick',sort(unique([xticks,r_special])));
set(ax_phase1,'XTick',sort(unique([xticks,r_special])));
xticks=get(ax_mag2,'XTick');
set(ax_mag2,'XTick',sort(unique([xticks,r_special])));
set(ax_phase2,'XTick',sort(unique([xticks,r_special])));
end
end
figure(Fig_3D)
legend(legend_str,'interpreter','latex','Location','bestOutside')
figure(Fig_Nyq)
legend(legend_str,'interpreter','latex','Location','bestOutside')
legend(ax_r,legend_str,'interpreter','latex','Location','best')
legend(ax_i,legend_str,'interpreter','latex','Location','best')
legend(ax_mag1,legend_str,'interpreter','latex','Location','best')
legend(ax_mag2,legend_str,'interpreter','latex','Location','best')
legend(ax_mag3,legend_str,'interpreter','latex','Location','best')
set(groot,'DefaultAxesColorOrder','remove')
set(groot,'DefaultAxesLineStyleOrder','remove')
set(groot,'DefaultLineMarkerSize','remove');
set(groot,'DefaultLineLineWidth','remove');