|
102 | 102 |
|
103 | 103 | % Loop over uncertainties |
104 | 104 | for field=fieldnames(SC.SIG.RF{ord})' |
105 | | - % Check if individual cutoff is defined |
106 | | - if iscell(SC.SIG.RF{ord}.(field{1})) |
107 | | - SC.RING{ord}.(field{1}) = SC.SIG.RF{ord}.(field{1}){1} * SCrandnc(SC.SIG.RF{ord}.(field{1}){2}); |
108 | | - else |
109 | | - SC.RING{ord}.(field{1}) = SC.SIG.RF{ord}.(field{1}) * SCrandnc(par.nSig); |
110 | | - end |
| 105 | + % Apply errors |
| 106 | + SC.RING{ord}.(field{1}) = rndn_cutoff(SC.SIG.RF{ord}.(field{1}),par.nSig); |
111 | 107 | end |
112 | 108 | end |
113 | 109 | end |
|
152 | 148 | if regexp(field{1},'Noise') |
153 | 149 | SC.RING{ord}.(field{1}) = SC.SIG.BPM{ord}.(field{1}); |
154 | 150 | else |
155 | | - % Check if individual cutoff is defined |
156 | | - if iscell(SC.SIG.BPM{ord}.(field{1})) |
157 | | - SC.RING{ord}.(field{1}) = SC.SIG.BPM{ord}.(field{1}){1} .* SCrandnc(SC.SIG.BPM{ord}.(field{1}){2},size(SC.SIG.BPM{ord}.(field{1}){1})); |
158 | | - else |
159 | | - SC.RING{ord}.(field{1}) = SC.SIG.BPM{ord}.(field{1}) .* SCrandnc(par.nSig,size(SC.SIG.BPM{ord}.(field{1}))); |
160 | | - end |
| 151 | + % Apply errors |
| 152 | + SC.RING{ord}.(field{1}) = rndn_cutoff(SC.SIG.BPM{ord}.(field{1}),par.nSig); |
161 | 153 | end |
162 | 154 | end |
163 | 155 | end |
|
168 | 160 | % Circumference error |
169 | 161 | function SC = applyCircumferenceError(SC,par) |
170 | 162 | if isfield(SC.SIG,'Circumference') |
171 | | - % Define circumference error |
172 | | - circScaling = 1 + SC.SIG.Circumference * SCrandnc(par.nSig,1,1); |
| 163 | + % Check if individual cutoff is defined |
| 164 | + if iscell(SC.SIG.Circumference) |
| 165 | + circScaling = 1 + SC.SIG.Circumference{1} * SCrandnc(SC.SIG.Circumference{2},1,1); |
| 166 | + else |
| 167 | + circScaling = 1 + SC.SIG.Circumference * SCrandnc(par.nSig,1,1); |
| 168 | + end |
173 | 169 | % Apply circumference error |
174 | 170 | SC.RING = SCscaleCircumference(SC.RING,circScaling,'rel'); |
175 | 171 | fprintf('Circumference error applied.\n'); |
|
182 | 178 | function SC = applySupportAlignmentError(SC,par) |
183 | 179 |
|
184 | 180 | % Loop over different support types |
185 | | - for type = {'Girder','Plinth','Section'} |
| 181 | + for type = {'Section','Plinth','Girder'} |
186 | 182 | % Check if support type is registered |
187 | 183 | if ~isfield(SC.ORD,type{1}) |
188 | 184 | continue; |
|
201 | 197 | if isempty(strfind(field{1},type{1})) |
202 | 198 | continue; |
203 | 199 | end |
204 | | - |
| 200 | + |
205 | 201 | % Generate random error for support structure beginning |
206 | | - if iscell(SC.SIG.Support{ordPair(1)}.(field{1})) |
207 | | - % Individual cutoff is given |
208 | | - SC.RING{ordPair(1)}.(field{1}) = SC.SIG.Support{ordPair(1)}.(field{1}){1} .* SCrandnc(SC.SIG.Support{ordPair(1)}.(field{1}){2},size(SC.SIG.Support{ordPair(1)}.(field{1}){1})); |
209 | | - else |
210 | | - SC.RING{ordPair(1)}.(field{1}) = SC.SIG.Support{ordPair(1)}.(field{1}) .* SCrandnc(par.nSig,size(SC.SIG.Support{ordPair(1)}.(field{1}))); |
211 | | - end |
| 202 | + SC.RING{ordPair(1)}.(field{1}) = rndn_cutoff(SC.SIG.Support{ordPair(1)}.(field{1}),par.nSig); |
212 | 203 |
|
213 | 204 | % Check if uncertanty is specified for endpoint |
214 | 205 | if length(SC.SIG.Support)>=ordPair(2) && isfield(SC.SIG.Support{ordPair(2)},field{1}) |
215 | 206 | % Generate random error for support structure endpoint |
216 | | - if iscell(SC.SIG.Support{ordPair(2)}.(field{1})) |
217 | | - % Individual cutoff is given |
218 | | - SC.RING{ordPair(2)}.(field{1}) = SC.SIG.Support{ordPair(2)}.(field{1}){1} .* SCrandnc(SC.SIG.Support{ordPair(2)}.(field{1}){2},size(SC.SIG.Support{ordPair(2)}.(field{1}){1})); |
219 | | - else |
220 | | - SC.RING{ordPair(2)}.(field{1}) = SC.SIG.Support{ordPair(2)}.(field{1}) .* SCrandnc(par.nSig,size(SC.SIG.Support{ordPair(2)}.(field{1}))); |
221 | | - end |
| 207 | + SC.RING{ordPair(2)}.(field{1}) = rndn_cutoff(SC.SIG.Support{ordPair(2)}.(field{1}),par.nSig); |
222 | 208 | else |
223 | 209 | % Copy support structure endpoint from structure beginning |
224 | 210 | SC.RING{ordPair(2)}.(field{1}) = SC.RING{ordPair(1)}.(field{1}); |
|
284 | 270 | end |
285 | 271 | % Loop over uncertanties |
286 | 272 | for field=fieldnames(SC.SIG.Mag{ord})' |
287 | | - % Check if individual cutoff is given |
288 | | - if iscell(SC.SIG.Mag{ord}.(field{1})) |
289 | | - nSig = SC.SIG.Mag{ord}.(field{1}){2}; |
290 | | - sig = SC.SIG.Mag{ord}.(field{1}){1}; |
291 | | - else |
292 | | - nSig = par.nSig; |
293 | | - sig = SC.SIG.Mag{ord}.(field{1}); |
294 | | - end |
295 | | - |
296 | 273 | % Bending angle error gets applied differently |
297 | 274 | if strcmp(field{1},'BendingAngle') |
298 | | - SC.RING{ord}.BendingAngleError = sig * SCrandnc(nSig,1,1); |
| 275 | + SC.RING{ord}.BendingAngleError = rndn_cutoff(SC.SIG.Mag{ord}.(field{1}),par.nSig); |
299 | 276 | else |
300 | | - SC.RING{ord}.(field{1}) = sig .* SCrandnc(nSig,size(sig)); |
| 277 | + SC.RING{ord}.(field{1}) = rndn_cutoff(SC.SIG.Mag{ord}.(field{1}),par.nSig); |
301 | 278 | end |
302 | 279 | end |
303 | 280 |
|
304 | 281 | end |
305 | 282 | end |
306 | 283 |
|
307 | 284 |
|
| 285 | +function error = rndn_cutoff(field,nSig0) |
| 286 | + % Check if cutoff is defined explicitly |
| 287 | + if iscell(field) |
| 288 | + error = field{1} .* SCrandnc(field{2},size(field{1})); |
| 289 | + else |
| 290 | + error = field .* SCrandnc(nSig0,size(field)); |
| 291 | + end |
| 292 | +end |
0 commit comments