-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquestion02.m
137 lines (109 loc) · 2.62 KB
/
question02.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
clear all
close all
f = 0:0.001:10;
parameters = load('question01parameters.mat');
%% Tube 1
E1tests = [ 9e6 8e6 7e6 6e6 5e6 ];
ZinCReal = cell(length(E1tests),1);
ZinCImag = cell(length(E1tests),1);
legendCell = cell(length(E1tests),1);
for k = 1:length(E1tests);
parameters.E1 = E1tests(k);
[ZinCReal{k},ZinCImag{k}] = ZvsF(f,parameters);
end
figure
subplot(2,1,1)
ylim([1 100])
hold on
for k = 1:length(E1tests);
plot(f,ZinCReal{k})
legendStrTemp = strcat(['E1 = ' sprintf('%.*e',1,E1tests(k)) ' ']);
legendCell{k} = legendStrTemp;
end
title('Modulus vs. Frequency')
xlabel('Frequency (Hz)')
ylabel('Modulus')
legend(legendCell)
subplot(2,1,2)
ylim([-2 2])
hold on
for k = 1:length(E1tests);
plot(f,ZinCImag{k})
end
plot(f,zeros([1,length(f)]),'k--')
title('Phase vs. Frequency')
xlabel('Frequency (Hz)')
ylabel('Phase (radians)')
legend(legendCell)
parameters.E1 = 7e6;
%% Tube 2
E2tests = [ 8e6 7e6 6e6 5e6 4e6 ];
ZinCReal = cell(length(E2tests),1);
ZinCImag = cell(length(E2tests),1);
legendCell = cell(length(E2tests),1);
for k = 1:length(E2tests);
parameters.E2 = E2tests(k);
[ZinCReal{k},ZinCImag{k}] = ZvsF(f,parameters);
end
figure
subplot(2,1,1)
ylim([1 100])
hold on
for k = 1:length(E2tests);
plot(f,ZinCReal{k})
legendStrTemp = strcat(['E2 = ' sprintf('%.*e',1,E2tests(k)) ' ']);
legendCell{k} = legendStrTemp;
end
title('Modulus vs. Frequency')
xlabel('Frequency (Hz)')
ylabel('Modulus')
legend(legendCell)
subplot(2,1,2)
ylim([-2 2])
hold on
for k = 1:length(E2tests);
plot(f,ZinCImag{k})
end
plot(f,zeros([1,length(f)]),'k--')
title('Phase vs. Frequency')
xlabel('Frequency (Hz)')
ylabel('Phase (radians)')
legend(legendCell)
parameters.E2 = 6e6;
%% Both Tubes
E1tests = [ 9e6 8e6 7e6 6e6 5e6 ];
E2tests = [ 9e6 8e6 7e6 6e6 5e6 ];
ZinCReal = cell(length(E1tests),1);
ZinCImag = cell(length(E1tests),1);
legendCell = cell(length(E1tests),1);
for k = 1:length(E1tests);
parameters.E1 = E1tests(k);
parameters.E2 = E2tests(k);
[ZinCReal{k},ZinCImag{k}] = ZvsF(f,parameters);
end
figure
subplot(2,1,1)
ylim([1 100])
hold on
for k = 1:length(E1tests);
plot(f,ZinCReal{k})
legendStrTemp = strcat(['E1 = ' sprintf('%.*e',1,E1tests(k)) ', E2 = ' sprintf('%.*e',1,E2tests(k))]);
legendCell{k} = legendStrTemp;
end
title('Modulus vs. Frequency')
xlabel('Frequency (Hz)')
ylabel('Modulus')
legend(legendCell)
subplot(2,1,2)
ylim([-2 2])
hold on
for k = 1:length(E1tests);
plot(f,ZinCImag{k})
end
plot(f,zeros([1,length(f)]),'k--')
title('Phase vs. Frequency')
xlabel('Frequency (Hz)')
ylabel('Phase (radians)')
legend(legendCell)
parameters.E1 = 7e6;
parameters.E2 = 6e6;