NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/plots/pp_hours.m

Revision 495 (checked in by cbc, 11 years ago)

Initial import of Stark code.

Line 
1 function [line_handle] = pp(varargin)
2
3 %PP  Plots and manipulates polar plots
4 %
5 %   PP(THETA,R) plots the polar representation of THEATA and R with the
6 %   centre and max values being the minimum and maximum values of R.
7 %
8 %   PP(THETA,R,S) plots as above, where S is a character string made from
9 %   standard plotting formatting in the PLOT function. See HELP PLOT.
10 %
11 %   PP(THETA,R,A) plots as above, but within the axis limits of A. A is
12 %   a 1x2 or 2x1 array containing the centre value and maximum value of
13 %   the polar plot ring axes.
14 %
15 %   PP(THETA,R,'Property 1',...) plots as above with the selected
16 %   properties. See below for propterties.
17 %
18 %   PP('Property 1',...) edits the current figure (if it is a polar plot
19 %   figure) to the assigned properties.
20 %
21 %   PP('Trace', 3, 'Property 1', ... , 'Trace', 1, 'Property 10', ... )
22 %   changes properties of trace 3 and trace one. Any properties defined
23 %   after the trace belong to that trace until a new trace number is
24 %   defined.
25 %
26 %             PROPERTIES:            DEFAULT          POSSIBLE
27 %           ---------------        -----------       ----------
28 %
29 %   GENERAL PLOTTING:
30 %          'ThetaDirection'            'ccw'          'cw','ccw'
31 %          'LineStyle'                 '-'             see PLOT
32 %          'LineWidth'                  1              1,2,...
33 %          'LineColor'                 'b'             see PLOT or RGB vector
34 %          'Marker'                    'none'          see PLOT
35 %          'ThetaStartAngle'            0              0-360
36 %          'ppStyle'                    0              0,1,2
37 %
38 %   AXES RANGE:
39 %          'MaxValue'                  'max'           numeric value (greater than CetreValue)
40 %          'CentreValue'               'min'           numeric value (less than MaxValue)
41 %
42 %   ANGLE AXIS:
43 %          'AngleAxis'                 'on'           'on','off','none'
44 %          'AngleStep'                  30             numeric value
45 %          'AngleAxisStyle'            ':'             see PLOT
46 %          'AngleAxisColor'             black          see PLOT or RGB vector
47 %          'AngleLineWidth'             1              1,2,...
48 %          'AngleLabel'                'on'           'on','off','none'
49 %          'AngleLabelStep'             same as axis   numeric value
50 %          'AngleFontSize'              10             numeric value
51 %          'AngleFontColor'             black          see PLOT or RGB vector
52 %          'AngleFontWeight'           'normal'       'normal','bold','light','demi'
53 %          'AngleDegreeMark'           'off'          'off',0, 'on',1
54 %
55 %   RING AXIS:
56 %          'NumRings'                   4              integer value >= 0   
57 %          'RingAxis'                  'on'           'on','off','none'
58 %          'RingAxisStyle'             ':'             see PLOT
59 %          'RingAxisColor'              black          see PLOT or RGB vector
60 %          'RingStep'            cal. from No. rings   integer value > 0
61 %          'RingLineWidth'              0.1            1,2,...
62 %          'RingLabel'                 'on'           'on','off','none'
63 %          'RingFontSize'               10             numeric value
64 %          'RingFontWeight'            'normal'       'normal','bold','light','demi'
65 %          'RingFontColor'              black          see PLOT or RGB vector
66 %          'AxisOuterRingStyle'        '-'             see PLOT
67 %          'RingUnits'                 ''              Some String Value
68 %          'MagMarkAngle'               45             0-360
69 %
70 %   FIGURE PROPERTIES:
71 %          'FigurePosition'                     
72 %          'FigureBackgroundColor'   
73 %          'PlotBackgroundColor'             
74 %          'PlotBorderColor'                 
75 %          'PlotBorderLineColor'     
76 %
77 %   TRACE:
78 %          'Trace'                      1              any trace number
79 %          'LineStyle'                 '-'             see PLOT
80 %          'LineWidth'                  1              1,2,...
81 %          'LineColor'                 'b'             see PLOT or RGB vector
82 %          'Marker'                    'none'          see PLOT
83 %          'RhoData'                   
84 %          'ThetaData'
85 %
86 %   OTHER:
87 %          'SetupVariables'
88 %          'Axes'                     
89 %
90
91 % Author:         Robert Schlub
92 % Last Modified:  4th December 2002
93
94
95 %Setup global variables that will be used within function blocks
96 global DB args oc NewTrace Traces CreateNewFigure r theta tc axis_limits HoldWasOn ErrorFlag ppStyle;
97
98 %default settings
99 tc = struct( 'line_color',    [0 0 1]            ,...   RGB or PLOT value of line color
100     'line_style',             '-'                ,...   line style string same as PLOT function
101     'line_width',             1                  ,...   line width of trace
102     'line_marker',            'none'             ,...   line marker style
103     'trace_index',            1                  ,...   trace number identifier
104     'trace_string',           ''                 );%    trace string identifier
105
106
107 oc = struct( 'theta_start',            0                  ,...   theta start angle in degrees
108     'angle_step',             30                 ,...   number of theta markers                   
109     'angle_label_step',       0                  ,...   number of theta labels
110     'number_of_rings',        4                  ,...   number of magnitude rings
111     'max_mag',                'max'              ,...   maximum ring magnitude ('max' makes data's max value it)
112     'centre_value',           'min'              ,...   minimum ring value (centre value)
113     'background_color',       [0.8 0.8 0.8]      ,...   background color
114     'theta_direction',        'ccw'              ,...   direction of theta increment
115     'ring_step',              0                  ,...   step size of rings
116     'mag_mark_angle',         45                 ,...   angle of magnitude labels
117     'axes_hold',              'off'              ,...   flag to tell whether axis hold is on or off
118     'ring_color',             'k'                ,...   ring axis color
119     'ring_style',             ':'                ,...   ring axis style
120     'ring_line_width',       0.1                 ,...   ring axis line width
121     'ring_border_line_width',0.5                 ,...   ring border line width
122     'angle_axis',             ''                 ,...   angle axis is ON or OFF
123     'angle_color',            'k'                ,...   angle axis color
124     'angle_style',            ':'                ,...   angle axis style
125     'angle_label',            ''                 ,...   angle axis labels are ON or OFF
126     'angle_line_width',      0.1                 ,...   angle axis line width
127     'angle_font_size',        10                 ,...   angle axis font size
128     'angle_font_color',       'k'                ,...   angle axis font color
129     'angle_font_weight',      'normal'           ,...   angle axis font weight
130     'angle_degree_mark',      'off'              ,...   degree symbol placed with angle text
131     'ring_axis',              ''                 ,...   ring axis is ON or OFF
132     'ring_label',             ''                 ,...   ring axis labels are ON or OFF
133     'ring_font_size',         10                 ,...   ring axis font size
134     'ring_font_color',        'k'                ,...   ring axis font color
135     'ring_font_weight',       'normal'           ,...   ring axis font weight
136     'figure_position',        [300 150 583 500]  ,...   figure position and size
137     'outer_ring_style',       '-'                ,...   ring axis border style
138     'ring_units',             ''                 ,...   ring axis units string
139     'plot_area_color',        [1 1 1]            ,...   color inside ring axes (the plot area)
140     'circ_border_color',      ''                 ,...   color of circular border
141     'circ_border_line_color', ''                 );%    color of line defining circular border
142
143
144
145 %First Argument defines what is expected as the user input to say which option is wanted
146 %First Flag is: 1 if there is data expected after the argurment
147 %               0 if no data expected but contents of third column gets copied into 4th column variable
148 %Second Flag is : s if string data only is expected
149 %                 v if numerical data only is expected (values)
150 %                 vs if numerical or string data can be accepted
151 %                 st if structure data expected
152 %Final string variable points to which variable which the corresponding data is to be assigned to
153
154 %           Argument        flag flag  variable to alter
155 args = {'SetupVariables'           1 'st'  'oc'                          %initial setup variables
156     'ThetaDirection'       1 's'   'oc.theta_direction'          %theta direction (CW/CCW)
157     'CentreValue'              1 'vs'  'oc.centre_value'             %centre value of graph
158     'MaxValue'                 1 'vs'  'oc.max_mag'                  %max value of graph
159     'LineStyle'                1 's'   'Traces{TraceIndex*2}.line_style'               %trace style
160     'LineWidth'                1 'v'   'Traces{TraceIndex*2}.line_width'               %trace width
161     'LineColor'                1 'vs'  'Traces{TraceIndex*2}.line_color'               %trace color
162     'Marker'                   1 's'   'Traces{TraceIndex*2}.line_marker'              %trace marker style
163     'ThetaStartAngle'          1 'v'   'oc.theta_start'              %theta start angle (refer note below)
164     'AngleAxis'                1 's'   'oc.angle_axis'               %angle axis is ON or OFF
165     'AngleStep'                1 'v'   'oc.angle_step'               %angle axis step size (between axes)
166     'AngleAxisStyle'           1 's'   'oc.angle_style'              %angle axis style
167     'AngleAxisColor'           1 'vs'  'oc.angle_color'              %angle axis color
168     'AngleLineWidth'           1 'vs'  'oc.angle_line_width'         %angle axis line width
169     'AngleLabel'               1 's'   'oc.angle_label'              %angle axis label is ON or OFF
170     'AngleLabelStep'           1 'v'   'oc.angle_label_step'         %angle axis label step size
171     'AngleFontSize'            1 'v'   'oc.angle_font_size'          %angle axis label font size
172     'AngleFontColor'           1 'vs'  'oc.angle_font_color'         %angle axis font color
173     'AngleFontWeight'          1 's'   'oc.angle_font_weight'        %angle axis label font weight
174     'AngleDegreeMark',         1 'vs'   'oc.angle_degree_mark'        %marks the degrees character with angle text
175     'NumRings'                 1 'v'   'oc.number_of_rings'          %ring axes number
176     'RingAxis'                 1 's'   'oc.ring_axis'                %ring axis is on or off
177     'RingAxisStyle'            1 's'   'oc.ring_style'               %ring axis style
178     'RingAxisColor'            1 'vs'  'oc.ring_color'               %ring axis color
179     'RingStep'                 1 'v'   'oc.ring_step'                %ring axis step size
180     'RingBorderLineWidth'      1 'v'   'oc_ring_border_line_width'   %ring border line width
181     'RingLineWidth'            1 'vs'  'oc.ring_line_width'          %ring axis line width
182     'RingLabel'                1 's'   'oc.ring_label'               %ring axis labeling is ON or OFF
183     'RingFontSize'             1 'v'   'oc.ring_font_size'           %ring axis label font size
184     'RingFontWeight'           1 's'   'oc.ring_font_weight'         %ring axis label font size
185     'RingFontColor'            1 'vs'  'oc.ring_font_color'          %ring axis font color
186     'AxisOuterRingStyle'       1 's'   'oc.outer_ring_style'         %ring axis border (circumference) style
187     'RingUnits'                1 's'   'oc.ring_units'               %ring axis label units
188     'MagMarkAngle'             1 'v'   'oc.mag_mark_angle'           %ring axis label angle
189     'FigurePosition'           1 'vs'  'oc.figure_position'          %position and size of figure on screen
190     'FigureBackgroundColor'    1 'vs'  'oc.background_color'         %figure background color (outside plot area)
191     'PlotBackgroundColor'      1 'vs'  'oc.plot_area_color'          %plot area background color
192     'PlotBorderLineColor'      1 'vs'  'oc.circ_border_line_color'   %circular border line color
193     'PlotBorderColor'          1 'vs'  'oc.circ_border_color'        %circular border color
194     'Axis'                     1 'vs'  'axis_limits'                 %limits of axis
195     'Axes'                     1 'vs'  'axis_limits'                 %limits of axes (as in plural spelling but same result)
196     'Trace'                    1 'v'   'TraceIndex'                  %current trace number - used to edit plot parameters of the trace
197     'ThetaData',               1 'v'   'Traces{TraceIndex*2-1}(:,2)'     %Theta data
198     'RhoData',                 1 'v'   'Traces{TraceIndex*2-1}(:,1)'     %Rho Data
199     'ppStyle',                 1 'v'   'ppStyle'                     %A style of axes presentation
200 };
201 %NOTES:
202 %ThetaStartAngle is relative to the direction of theta. ie, a start angle of 90 will be 180 differnt between
203 %clock wise and counter clock wise direction of theta.
204
205 %Setup a space for Traces
206 Traces = '';
207
208 %set up the variable axis limits. It is a 1x2 array whose first element contains the centre value and second
209 %element contains the max magnitude.
210 axis_limits = [0 0];
211
212 %If ErrorFlag ever goes to 1 then will be quitting out
213 ErrorFlag = 0;
214
215 %Set default value of ppStyle
216 %Style Types:
217 %              0: No Changes
218 %              1: Default
219 %              2: Grey solid axes with 'dB' as ring units and degree marks present
220 %
221 ppStyle = 0;
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
237 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
239 %                                                                                       %
240 %                                         MAIN                                          %
241 %                                                                                       %
242 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
244 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
245
246 %First check all input arguments and ensure they are valid. Also get back a flag to say whether the new data
247 %is being added or not (if not, then simple figure/axes/current_trace properties are being changed
248 CheckInput(varargin);
249 if ErrorFlag, return; end
250
251 %if NewTrace == 0 or hold is on, then load the user_data from the current figure and fill 'oc' and 'Traces'
252 LoadExistingData;
253 if ErrorFlag, return; end
254
255 %Assign input arguments to their corresponding variables
256 AssignInput(varargin); %this will overwrite any varibales in oc etc that have been updated
257 if ErrorFlag, return; end
258
259 AssignStyle(ppStyle);
260 if ErrorFlag, return; end
261
262 CheckAxisLimits;
263 if ErrorFlag, return; end
264
265 CheckPlotLimits;
266 if ErrorFlag, return; end
267
268 SetupFigure;
269
270 %Save Userdata to figure
271 UserData{1} = 'Bobs Polar Plot';
272 UserData{2} = oc;
273 UserData = [UserData Traces];
274 set(gcf,'UserData', UserData);      %save updated trace data into figure
275
276 PlotAxes;
277
278 for i=1:2:length(Traces)
279     ThetaPlot = SetupTheta(  Traces{i}(:,2)  );
280     DB = 0;
281     if(i>1)
282         DB = 1;
283 %       keyboard
284     end
285
286     [RPlot ThetaPlot PlotProperties] = SetupR(  Traces{i}(:,1)  ,  ThetaPlot  );
287     PlotTrace(ThetaPlot, RPlot, PlotProperties, Traces{i+1});
288 end
289
290 if HoldWasOn == 0
291     hold off
292 end
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
309 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
310 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
311 %                                                                                       %
312 %                                     CHECK INPUT                                       %
313 %                                                                                       %
314 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
315 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
316 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
317
318 %This function will go through the input string entered into pp(). It will simply ensure
319 %valid ordering of commands and will assign NewTrace a value depending on if Trace Data
320 %is present or not in the input arguments
321
322 function CheckInput(VariableArgIn)
323
324 global args NewTrace ErrorFlag;
325
326 %find the number or inputs and the number of possible arguments
327 num_inputs = length(VariableArgIn);
328
329 m = 0;
330 NewTrace = 0;   %This is set if there is data (in the form of a trace) to be added to the plot
331
332 %now, step through all the arguments and compare them to valid arguments
333 while m < num_inputs   %number of inputs into function (ie number of variables separated by commas)
334     m = m + 1;
335     n = 0;
336    
337     %if the first element is numeric check the second element to ensure it is also numberic and the same length
338     %as theta and r must be the same sizes
339     if m == 1 & isnumeric(VariableArgIn{m})
340         %check to make sure there is a second input argument
341         if num_inputs < 2
342             DispError('No Rho values Present');
343             return
344         end
345         if isnumeric(VariableArgIn{m+1}) & max(length(VariableArgIn{m+1})) == max(length(VariableArgIn{m}))
346             m = 2;   %move to after the RHO element which was just analysed
347             %now check to see if the next input is the axes limits (it will be if its a numeric value)
348             %this is the only case the third input can be numeric (without a property identifier)
349             if num_inputs > 2
350                 if isnumeric(VariableArgIn{m+1})     %m = 3 now
351                     m = 3;  %move to after the AXIS LIMITS variable which was just analysed
352                 end
353             end             
354         else
355             DispError('THETA and R must be an equal length 1xm or mx1 array or variables');
356             return
357         end
358        
359         %if we have got here without error then there is a valid new trace being added or created
360         NewTrace = 1;
361         continue; %skip through to start of while loop again
362     end
363    
364     %search for the string in the args array and return the args index
365     index = FindArgsIndex(VariableArgIn{m});
366    
367     %if an index was found and another agument is expected to complete it, then ensure that
368     %the input after it is valid (string, value of struct)
369     if index > 0 & args{index,2} == 1              %if another argument is expected to complete this one
370             if m + 1 > num_inputs       %if there is no more completeing argument   
371                 DispError(['No input argument for "' VariableArgIn{m} '"'])  %exit
372                 return
373             end
374             %check 2nd flag of args to see if string or number is expected
375             switch args{index,3}
376             case 'v'                                         %assign variable with number       
377                 if ischar(VariableArgIn{m+1})
378                     DispError(['The input argument for "' VariableArgIn{m} '" must be numerical']);
379                     return
380                 end        %note the lack of break sends the case through to string check
381             case 's'                                         %assign variable with string
382                 if ischar(VariableArgIn{m+1}) == 0
383                     DispError(['The input argument for "' VariableArgIn{m} '" must be a string']);
384                     return
385                 end         
386             case 'vs'
387                 if (ischar(VariableArgIn{m+1}) == 0 & isnumeric(VariableArgIn{m+1}) == 0)
388                     DispError(['The input argument for "' VariableArgIn{m} '" must be either numerical, or a string (not a cell, struct etc.)']);
389                     return
390                 end
391             case 'st'  %the only structure  is the 'SetupVariables' cell
392                 if isstruct(VariableArgIn{m+1}) == 0
393                     DispError(['The input argument for "' VariableArgIn{m} '" must be a structure']);
394                     return
395                 end
396             end
397             m = m+1;  %increment the m counter so that input of the argument is not checked as an argument
398        
399     %in the case that the string wasn't found in args, it might be a standard plotting string. This will only
400     %happen if m = 3 and a trace is being added. If thats the case then ensure then ensure the string is valid
401     elseif index == 0 & m == 3 & NewTrace & length(VariableArgIn{m}) <= 4
402         CheckStandardPlot(VariableArgIn{m});     %this will quit out if there is a syntax error in the string
403         if ErrorFlag, return; end
404
405         %Otherwise the string is not valid
406     else
407         DispError(['The argument "' VariableArgIn{m} '" is not valid. See help']);
408         return
409     end
410 end
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
426 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
427 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
428 %                                                                                       %
429 %                      LoadExistingData - LOAD EXISTING DATA                            %
430 %                                                                                       %
431 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
432 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
433 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
434
435 %If hold is on or existing figure properties are being modified, then load the existing figures user_data
436 function LoadExistingData
437
438 global Traces oc NewTrace CreateNewFigure HoldWasOn;
439
440 %Default is to Create a new figure
441 CreateNewFigure = 1;
442
443 %Default HoldWasOn flag is 0 (ie hold was not on)
444 HoldWasOn = 0;
445
446 if max(findobj) ~= 0
447     %if hold is on then set the HoldWasOn flag so it can be turned on after all plotting complete
448
449     if ishold
450         HoldWasOn = 1;
451     end
452    
453     %if the current figure has hold on or we are editing an existing figure then we need to check to make sure its valid
454     if ishold | NewTrace==0   
455         user_data = get(gcf, 'UserData');
456         if ~strcmp(user_data{1}, 'Bobs Polar Plot')
457             DispError('Current figure is not a valid polar plot figure - it must be created using the pp function');
458             return
459         end
460
461         %If the figure is valid, then load the oc structure from it
462         oc = user_data{2};
463
464         %Load the existing Traces
465         if(length(user_data)>2)
466             Traces = cell(1,length(user_data)-2);
467             for i=1:length(user_data)-2
468                 Traces{i} = user_data{i+2};
469             end
470         end
471        
472         %if hold is on, or just properties are being added then we don't want to be creating a new figure later on
473         CreateNewFigure = 0;
474     end
475     %Otherwise if no figure is present but no new trace data exists then there is an error
476 elseif NewTrace == 0
477     DispError('No figure to modify properties of');
478     return
479 end
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
502 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
503 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
504 %                                                                                       %
505 %                                     ASIGN INPUT                                       %
506 %                                                                                       %
507 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
508 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
509 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
510
511 function AssignInput(VariableArgIn)
512
513 global theta r args axis_limits NewTrace Traces tc oc ppStyle;
514
515 num_inputs = length(VariableArgIn);
516
517 %set default trace
518 TraceIndex = 1;
519
520 m = 0; %needs to be zero for the while loop 35 lines below
521
522 %First assign theta, r and axis_limits if a new trace is being entered
523 if NewTrace
524
525     %If a trace is being added append two cells on the end of Traces (one for the r/theta values
526     %and the other for tc)
527     Traces = [Traces cell(1,2)];
528    
529     %set the trace number an unassigned number
530     TraceIndex = length(Traces)/2;
531    
532     %setup the default trace properties structure;
533     tc.trace_index = TraceIndex;
534     Traces{TraceIndex*2} = tc;
535
536     m = 1;    %Look at the first element of VariableArgIn (which should be the theta data)
537
538     theta = VariableArgIn{m};  %Get the Theta Data
539    
540     r = VariableArgIn{m+1};   %Get the Rho Data
541
542     %set theta, rho and original theta to be column vectors if they aren't already
543     [rows cols] = size(theta);
544     if rows == 1
545         theta = theta';
546     end
547     [rows cols] = size(r);
548     if rows == 1
549         r = r';
550     end
551
552     %assign the theta and r values to the appropriate trace
553     Traces{TraceIndex*2-1} = [r theta];
554
555     m = 2;   %move to the RHO element which was just analysed
556    
557     %now check to see if the next input is the axes limits (it will be if its a numeric value) or
558     %the standard plot string (it will be if its a string that can't be found)
559     if num_inputs > 2
560         %if numeric, then must be axis limits
561         if isnumeric(VariableArgIn{m+1})     %m = 2 now (3 lines up)
562             axis_limits = VariableArgIn{m+1};
563             m = 3;  %move to the axis limits variable which was just analysed
564                          
565         %if string and non existant in args, then must be standard plotting values
566         elseif FindArgsIndex(VariableArgIn{m+1}) == 0
567             [Color, Marker, Style] = CheckStandardPlot(VariableArgIn{m+1});     
568             %Assign the color, marker and style if they were defined
569
570             if ~isempty(Color)
571                 Traces{TraceIndex*2}.line_color = Color;
572             end
573             if ~isempty(Marker)
574                 Traces{TraceIndex*2}.line_marker = Marker;
575             end
576             if ~isempty(Style)
577                 Traces{TraceIndex*2}.line_style = Style;
578             end             
579             m = 3;
580         end
581     end
582 end
583
584 %now, step through all the remaining string arguments and compare them to valid arguments (in args)
585 while m < num_inputs   %number of inputs into function (ie number of variables separated by commas)
586     m = m + 1;
587    
588     %find the index in args of the current input argument - we know the index exists as error checking
589     %has been done previously
590     index = FindArgsIndex(VariableArgIn{m});
591    
592     %if another argument is expected to complete this one then assign it (error checking has already
593     %been performed)
594     if args{index,2} == 1
595         eval([args{index,4} '= VariableArgIn{m+1};'])
596         m = m+1;  %increment the m counter so that input of the argument is not checked as an argument
597     else   %if no other arugument is needed assign third colum of args to variable in 4th column
598         eval([args{index,4} '= args{index,3}']);
599     end         
600 end   
601
602 %NOTES:
603 %
604 %     TaceIndex:       The user must enter the argument "..., 'Trace', 3, ..." for trace parameters
605 %                      of trace 3 to be altered. In doing so, the while loop above will set TraceIndex
606 %                      to 3. Afterwards, when line style/color etc are altered the evaluation
607 %                      'Traces{TraceIndex*2}.line_style' (see args) will be used so trace 3 will have
608 %                      its properties successfully altered.
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
632 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
633 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
634 %                                                                                       %
635 %                                FIND ARGS INDEX                                        %
636 %                                                                                       %
637 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
638 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
639 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
640
641 function [index] = FindArgsIndex(StringToFind)
642 global args;
643 index = 1;    %start at the first row
644
645 %search through the args struct till find index varibale in StringToFind
646 while ~strcmp(args{index,1},StringToFind)
647     index = index + 1;
648    
649     %if searched through entire args rows and couldn't find a match then break and return 0
650     if index > length(args(:,1))
651         index = 0;
652         break;
653     end
654 end
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
676 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
677 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
678 %                                                                                       %
679 %                             CHECK AXIS LIMITS                                         %
680 %                                                                                       %
681 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
682 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
683 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
684
685 function CheckAxisLimits
686 global oc axis_limits args
687
688 %check to see if the axis_limits array elments are empty. If they are not, then it means they have been
689 %filled by the user in the arguments of the function call. Therefore, change the appropriate centre value
690 %and/or maximum magnitude. Because this happens after the assigning of arguments and their variables (above),
691 %then if the 'CentreValue' or 'MaxMag' arguments were used, then they will be overwritten by the axis_limits
692 if isnumeric(axis_limits) & (size(axis_limits) == [1 2] | size(axis_limits) == [2 1])
693     %if both are zero then user hasn't changed axis (or if they have entered [0 0], then its invalid
694     %because you can't have centre value and max mag equal and therefore this pretends that they haven't
695     %been this stupid on purpose)   
696     if axis_limits(1) ~= 0 | axis_limits(2) ~= 0
697         %but sometimes, you just have to protect the users from themselves
698         if axis_limits(1) == axis_limits(2)
699             disp(' ');disp('Cannot make centre value and maximum mag value the same');disp(' ');
700         else
701             %if valid then assign the centre and max variables to their vew values
702             oc.centre_value = axis_limits(1);                      %set the center value to the first element
703             oc.max_mag = axis_limits(2);                           %set the max value to the second element
704         end
705     end
706 elseif ischar(axis_limits) & (strcmpi(axis_limits,'off') | strcmpi(axis_limits,'none'))
707     oc.ring_axis = 'off';
708     oc.angle_axis = 'off';
709 elseif ischar(axis_limits) & strcmpi(axis_limits,'on')
710     oc.ring_axis = 'on';
711     oc.angle_axis = 'on';
712 else
713     DispError('"Axis" must be followed by 1x2 or 2x1 numerical vector, or by "on", "off" or "none" strings');
714     return
715 end
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
734 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
735 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
736 %                                                                                       %
737 %                                  SETUP FIGURE                                         %
738 %                                                                                       %
739 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
740 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
741 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
742 function SetupFigure
743
744 global CreateNewFigure oc
745
746 %If creating a new figure (flag set in LoadExistingData) then create one
747 %if CreateNewFigure
748 %    figure;
749 %else
750     clf reset;   %Otherwise if hold is on, or property modification only, then reset
751     %end              %the current figure for full redraw
752
753 %Set the figure properties
754 set(gcf,'Color',oc.background_color,'Position',oc.figure_position)
755
756 %Turn hold on for drawing of axes and traces
757 hold on
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
777 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
778 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
779 %                                                                                       %
780 %                                     PLOT AXES                                         %
781 %                                                                                       %
782 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
783 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
784 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
785
786 function PlotAxes
787
788 global oc r
789
790 %check to see if the degrees character is supposed to be plotted or not
791 degrees_string = '';
792 if(min(oc.angle_degree_mark == 1) == 1 | strcmp(oc.angle_degree_mark, 'on'))
793     degrees_string = '^{\o}';
794 end
795
796 %angle system for all corresponding axis
797 phi = 0:0.01:2*pi;
798
799 %make a circle for the plot's circular border
800 if ~isempty(oc.circ_border_line_color) | ~isempty(oc.circ_border_color)
801     border_line = 1.3;
802     x = border_line*cos(phi);
803     y = border_line*sin(phi);
804     if ~isempty(oc.circ_border_color)
805         fill(x,y,oc.circ_border_color,'LineStyle','none','HandleVisibility','off');
806     end
807     if ~isempty(oc.circ_border_line_color)
808         plot(x,y,'Color',oc.circ_border_line_color,'LineWidth',2,'HandleVisibility','off');
809     end
810     axis([-1.55 1.55 -1.55 1.55])
811 else
812     axis([-1.2 1.2 -1.2 1.2])
813 end
814
815 %Make up maximum magnitudes and minimum magnitudes
816 if strcmp(oc.max_mag,'max')
817     oc.max_mag = max(r);
818 end
819
820 if strcmp(oc.centre_value, 'min')
821     oc.centre_value = min(r);
822 end
823 plot_range = oc.max_mag - oc.centre_value;
824
825 %Draw the concentric circles (rings)
826 rings = 1;           %outer ring
827 if oc.ring_step == 0       %if number of rings defined (default) and not ring step then...
828     for i = 1:1:oc.number_of_rings
829         rings = [rings (oc.number_of_rings-i)/oc.number_of_rings];
830     end
831 else
832     if oc.ring_step > plot_range
833         disp('Warning: Ring step is larger than plotting range (max_mag - centre_value)');
834     end
835     for i = 1-oc.ring_step/plot_range:-oc.ring_step/plot_range:0  %If user define ring step then...
836         rings = [rings i];
837     end
838    
839 end   
840
841 %draw the plot fill circle only if one of the axes are on
842 if (~strcmpi(oc.ring_axis,'off') & ~strcmpi(oc.ring_axis,'none')) |...
843         (~strcmpi(oc.angle_axis, 'none') & ~strcmpi(oc.angle_axis, 'off'))
844     fill(cos(phi),sin(phi),oc.plot_area_color,'HandleVisibility','off')
845 end
846
847 %only draw the ring axis and its labels if axis is not set of 'OFF'
848 if ~strcmpi(oc.ring_axis, 'off') & ~strcmpi(oc.ring_axis, 'none')   
849     for i = 1:1:length(rings)     %plot the rings
850         x = rings(i)*cos(phi);
851         y = rings(i)*sin(phi);
852         if(rings(i) == 1)      %if on the outer ring, then make a solid line unless user specifies otherwise
853             plot(x,y,'Color',oc.ring_color,'LineStyle',oc.outer_ring_style,'LineWidth',oc.ring_border_line_width,...
854                 'HandleVisibility','off'); 
855         else
856             plot(x,y,'Color',oc.ring_color,'LineStyle',oc.ring_style,'LineWidth',oc.ring_line_width,...
857                 'HandleVisibility','off'); 
858         end
859     end
860    
861     %Draw on the text labeling the magnitude
862     angle_of_mark = oc.mag_mark_angle*pi/180;
863     if ~strcmpi(oc.ring_label,'off') & ~strcmpi(oc.ring_label,'none')  %the strcmpi is case insensitive       
864         for i = 1:1:length(rings)
865             x = (rings(i)+0.0*oc.max_mag)*cos(angle_of_mark);
866             y = (rings(i)+0.0*oc.max_mag)*sin(angle_of_mark);
867             if(rings(i) == 1)   %if on the outer ring's value, then insert units if user has defined them
868                 text(x,y,[num2str(round(rings(i)*plot_range*1000)/1000+round(oc.centre_value*1000)/1000) oc.ring_units],...
869                     'FontSize',oc.ring_font_size,  'FontWeight',oc.ring_font_weight,...
870                     'HorizontalAlignment','left',  'VerticalAlignment','bottom','Color',oc.ring_font_color,...
871                     'HandleVisibility','off')
872             else
873                 text(x,y,num2str(round(rings(i)*plot_range*1000)/1000+round(oc.centre_value*1000)/1000),...
874                     'FontSize',oc.ring_font_size,  'FontWeight',oc.ring_font_weight,...
875                     'HorizontalAlignment','left','VerticalAlignment','bottom','Color',oc.ring_font_color,...
876                     'HandleVisibility','off')
877             end
878         end
879     end
880 end
881
882 %Draw the angle markers
883 if strcmp(oc.angle_step,'')   %if angle step not defined
884     phi = (oc.theta_start:360/no_angle_marks:oc.theta_start+359)*pi/180;   %angle of marks
885     phit = oc.theta_start:360/no_angle_marks:oc.theta_start+359;           %angle of labels
886 else                       %if angle step defined
887     phi = (oc.theta_start:oc.angle_step:oc.theta_start+359)*pi/180;
888     phit = oc.theta_start:oc.angle_step:oc.theta_start+359;
889 end
890
891 %only draw the angle axis and its labels if axis is not set of 'OFF'
892 if ~strcmpi(oc.angle_axis, 'off') & ~strcmpi(oc.angle_axis, 'none')
893     for i = 1:1:length(phi)
894         x = 1*cos(phi(i));
895         y = 1*sin(phi(i));
896         plot([0 x],[0 y],'Color',oc.angle_color,'LineStyle',oc.angle_style,'LineWidth',oc.angle_line_width,...
897             'HandleVisibility','off')
898     end
899    
900     %if labels should not be put on every anlge mark then change the text anlges accordingly
901     if oc.angle_label_step ~= 0
902         phit = oc.theta_start:oc.angle_label_step:oc.theta_start+359;
903     end
904    
905     if strcmp(oc.theta_direction,'cw')
906         phit = -phit;
907     end
908    
909     %Draw on text labeling the angles
910     if ~strcmpi(oc.angle_label,'off') & ~strcmpi(oc.angle_label,'none')
911         for i = 1:1:length(phit)
912             x = 1*1.15*cos(phit(i)*pi/180);
913             y = 1*1.15*sin(phit(i)*pi/180);
914  %           text(x,y,[num2str(abs(phit(i))-oc.theta_start) degrees_string],...
915             text(x,y,[num2str((abs(phit(i))-oc.theta_start)/15,'%02d') ':00'],...
916                 'FontSize',oc.angle_font_size,'FontWeight',oc.angle_font_weight,...
917                 'HorizontalAlignment','center','VerticalAlignment','middle',...
918                 'Color',oc.angle_font_color,'HandleVisibility','off')
919         end
920     end
921 end
922 axis off
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
951 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
952 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
953 %                                                                                       %
954 %                                     SETUP THETA                                       %
955 %                                                                                       %
956 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
957 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
958 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
959 %transform the input to plot out correctly in cartesian coordinates
960 function theta = SetupTheta(theta)
961 global oc
962 theta = theta + oc.theta_start/180*pi;
963 if strcmp(oc.theta_direction,'cw')
964     theta = -theta;   
965 end
966                                          
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
990 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
991 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
992 %                                                                                       %
993 %                                     SETUP R                                           %
994 %                                                                                       %
995 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
996 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
997 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
998 function [norm_r, theta, PlotProperties] = SetupR(r, theta)
999 global oc DB
1000
1001 %make a note of the original maximum and minimum values of r
1002 max_r = max(r);
1003 min_r = min(r);
1004
1005 plot_range = oc.max_mag - oc.centre_value;
1006
1007 %shift r values so minimum is at 0 + centre value difference
1008 norm_r = r - oc.centre_value;
1009 norm_r = norm_r/plot_range;     %normalise r values between 0 and 1 where 0 is centre
1010 %value and 1 is max distance from centre (plot_range)
1011 %check all values and any that are negative (and therefore less than the centre value) are made
1012 %equal to the centre value
1013 for i = 1:1:length(norm_r)
1014     if norm_r(i) < 0
1015         norm_r(i) = 0;
1016     end
1017 end
1018
1019 %These normalised r values now need to be examined and any values outiside of the
1020 %the maximum magnitude need to be discarded. However, if there is interpolation between
1021 %2 points (one inside the max and one outside) then a new point on this interpolation needs
1022 %to be added in so the line from the point inside the axis still extends out to the outer
1023 %ring. Therefore, a new array of r values which only contain plottable values and additional
1024 %points that are needed is made.
1025
1026 PlotNumCounter = 0;          %Number of plots (ie number of sections within the unity circle)
1027 InPlotFlag = 0;           %if 1, this flag means that current points are in a plotting section
1028 PlotStartFlag = '';       %This will be an array containing the start points for the plot sections
1029 PlotBreakFlag = '';       %This will be an array containing the break points for the plot sections
1030
1031 for i = 1:1:length(norm_r)
1032     %the first point that is on or in the unity circle is allocated as the first section's start point
1033     if isempty(PlotStartFlag) & norm_r(i)<=1
1034         PlotStartFlag = i;
1035         InPlotFlag = 1;
1036         PlotNumCounter = 1;
1037     else       
1038         %If a point is outside the unity circle and not in the void between a break point
1039         %and start point then allocate the break point to the point previous to this one
1040         if(norm_r(i) > 1 & InPlotFlag == 1)
1041             PlotBreakFlag = [PlotBreakFlag i-1];
1042             InPlotFlag = 0;
1043         end
1044        
1045         %If a point is on or in the unity circle and currently is in the void between a break
1046         %point and start point then allocate this point as the start point of a new section
1047         if(norm_r(i) <= 1 & InPlotFlag == 0)
1048             PlotStartFlag = [PlotStartFlag i];
1049             InPlotFlag = 1;
1050             PlotNumCounter = PlotNumCounter + 1;
1051         end
1052     end
1053 end
1054
1055 %finally, if the last point was in a plotting section then have to define it as the break point
1056 if(InPlotFlag == 1)
1057     PlotBreakFlag = [PlotBreakFlag length(norm_r)];
1058 end
1059
1060
1061 %go through each of the start and end points and for each go to the point next to it that is in
1062 %the void (between start and break points) and calculate the gradient and then add in a point between
1063 %the void point and the valid point that lies on this gradient AND the unity circle. This procedure is
1064 %therefore only needed it a plot exists and it exceeds the unity boundary (ie the only break flag doesn't
1065 %index the last point in the set of data)
1066 if(PlotNumCounter > 0)
1067     for i = 1:1:PlotNumCounter
1068         if PlotStartFlag(i) ~= 1   %only look at section starts if its not the first point
1069             x = norm_r.*cos(theta);   %need to recalculate x and y every time incase norm_r and
1070             y = norm_r.*sin(theta);   %theta were changed in the previous loop
1071            
1072             %if the gradient between the void and valid points is infinity (ie x1=x2) then the line equation
1073             %simple becomes x=b, where b is the x coordinate of both points. We also know that for our wanted
1074             %point to be on the unity circle we need 1=sqrt(x^2+y^2) => 1=x^2+y^2. Therefore, as x=b, we can
1075             %find y as:
1076             %             y = 1-x^2 = 1-b^2
1077             %
1078             %Now, if the void point is in the y>0 quadrants, then the crossing point must occur in the y>0 part
1079             %of the unity circle. Conversely, if the void point has y<0, then the cross point must occur in the
1080             %y<0 semicircle of the unty circle
1081             if x(PlotStartFlag(i))==x(PlotStartFlag(i)-1)
1082                 Voidx = x(PlotStartFlag(i));
1083                 Voidy = 1-Voidx^2;
1084                 if(y(PlotStartFlag(i)-1)<0)
1085                     Voidy = -Voidy;
1086                 end
1087                 %however, if the gradient is defined, then we need to calc the gradient to find the point on the
1088                 %unity circle
1089             else 
1090                 if x(PlotStartFlag(i)-1)<x(PlotStartFlag(i))
1091                     gradient = (y(PlotStartFlag(i)) - y(PlotStartFlag(i)-1))/(x(PlotStartFlag(i)) - x(PlotStartFlag(i)-1));
1092                 elseif x(PlotStartFlag(i)-1)>x(PlotStartFlag(i))
1093           %          x(PlotStartFlag(i))
1094          %           y(PlotStartFlag(i))
1095         %            keyboard
1096         %            r(PlotStartFlag(i))
1097                     gradient = (y(PlotStartFlag(i)-1) - y(PlotStartFlag(i)))/(x(PlotStartFlag(i)-1) - x(PlotStartFlag(i)));
1098                 end   
1099                 %C is y intercept of y=mx+c eqation for a straign line
1100                 C = y(PlotStartFlag(i)) - gradient*x(PlotStartFlag(i));
1101                 m = gradient;
1102
1103                 %at the crossing point between line bewteen void and valid and unity circle we know the x,y
1104                 %coordinates must satisfy the straight line eqn y=mx+c and 1=sqrt(x^2+y^2) => 1=x^2+y+2.
1105                 %Rearranging this yeilds           
1106                 %                         0 = (m^2+1)x^2 + (2mc)x + (c^2-1)
1107                 %
1108                 %the roots of this can be solved and x found. Note that there will always be one or two
1109                 %real roots as this procedure is only being implemented when the line DOES cross the unity
1110                 %circle (there will only be one root when the line is a tangent to the unit circle).
1111                 Voidx = roots([m^2+1 2*m*C C^2-1]);
1112                 Voidy = m*Voidx+C;
1113                 %if there are two roots, check which x coordinate is between the void point and valid point
1114                 %and then use that as the true coordinate
1115                 x_limits = [x(PlotStartFlag(i)-1) x(PlotStartFlag(i))];
1116                 y_limits = [y(PlotStartFlag(i)-1) y(PlotStartFlag(i))];
1117                 if length(Voidx) == 2
1118                     if Voidx(1)>min(x_limits) &  Voidx(1)<max(x_limits) &  Voidy(1)>min(y_limits) &  Voidy(1)<max(y_limits)
1119                         Voidx = Voidx(1);
1120                         Voidy = Voidy(1);
1121                     else
1122                         Voidx = Voidx(2);
1123                         Voidy = Voidy(2);
1124                     end
1125                 end
1126             end
1127
1128             %insert new point into array or points
1129             norm_r = [norm_r(1:PlotStartFlag(i)-1); sqrt(Voidx^2+Voidy^2); norm_r(PlotStartFlag(i):length(norm_r))];
1130            
1131             %insert new angle into array of angles
1132             if(Voidx == 0)
1133                 new_theta = pi/2*sign(Voidy);   %this puts the point in the correct quadrant (CA or ST)
1134             else
1135                 new_theta = atan(Voidy/Voidx);
1136                 %if x is negative then the definition of atan needs to be added to 180 degrees
1137                 if(Voidx < 0)
1138                     new_theta = pi+new_theta;
1139                 end
1140             end
1141             theta = [theta(1:PlotStartFlag(i)-1); new_theta; theta(PlotStartFlag(i):length(theta))];
1142            
1143             %increment appropiate indecies in PlotStart and PlotBreak flags to take into accout the new points
1144             %(remembering you want the new points to be within the plotting segement)
1145             if(i < PlotNumCounter)  %if not at the last PlotStartFlag
1146                 PlotStartFlag(i+1:PlotNumCounter) = PlotStartFlag(i+1:PlotNumCounter) + 1;
1147             end
1148             PlotBreakFlag(i:PlotNumCounter) = PlotBreakFlag(i:PlotNumCounter) + 1;
1149         end
1150        
1151         %now do the same thing for the break flags, ie going from valid point to void
1152         %But only consider if the break is NOT the first element, or the break is NOT the last element
1153         if  (PlotBreakFlag(i) ~= length(norm_r))
1154             x = norm_r.*cos(theta);  %need to recalc x and y incase norm_r and theta were changed in previous
1155             y = norm_r.*sin(theta);  %if statement (for PlotStartFlag) or previous loop
1156            
1157             %refer to previous IF statement (for PlotStartFlag) for full explanation
1158             if x(PlotBreakFlag(i))==x(PlotBreakFlag(i)+1)
1159                 Voidx = x(PlotBreakFlag(i));
1160                 Voidy = 1-Voidx^2;
1161                 if(y(PlotBreakFlag(i)+1)<0)
1162                     Voidy = -Voidy;
1163                 end
1164             else
1165                 if x(PlotBreakFlag(i)+1)<x(PlotBreakFlag(i))
1166                     gradient = (y(PlotBreakFlag(i)) - y(PlotBreakFlag(i)+1))/(x(PlotBreakFlag(i)) - x(PlotBreakFlag(i)+1));
1167                 elseif x(PlotBreakFlag(i)+1)>x(PlotBreakFlag(i))
1168                     gradient = (y(PlotBreakFlag(i)+1) - y(PlotBreakFlag(i)))/(x(PlotBreakFlag(i)+1) - x(PlotBreakFlag(i)));
1169                 end
1170                 %C is y intercept of y=mx+c eqation for a straign line
1171                 C = y(PlotBreakFlag(i)) - gradient*x(PlotBreakFlag(i));
1172                 m = gradient;
1173                
1174                 Voidx = roots([m^2+1 2*m*C C^2-1]);
1175                 Voidy = m*Voidx+C;
1176                 %if there are two roots, check which x coordinate is between the void point and valid point
1177                 %and then use that as the true coordinate
1178                 x_limits = [x(PlotBreakFlag(i)+1) x(PlotBreakFlag(i))];
1179                 y_limits = [y(PlotBreakFlag(i)+1) y(PlotBreakFlag(i))];
1180                 if length(Voidx) == 2
1181                     if Voidx(1)>min(x_limits) &  Voidx(1)<max(x_limits) &  Voidy(1)>min(y_limits) &  Voidy(1)<max(y_limits)
1182                         Voidx = Voidx(1);
1183                         Voidy = Voidy(1);
1184                     else
1185                         Voidx = Voidx(2);
1186                         Voidy = Voidy(2);
1187                     end
1188                 end
1189             end
1190             %insert new point into array or points
1191
1192             norm_r = [norm_r(1:PlotBreakFlag(i)); sqrt(Voidx^2+Voidy^2); norm_r(PlotBreakFlag(i)+1:length(norm_r))];
1193            
1194             %calculate and insert new angle into array of angles
1195             if(Voidx == 0)
1196                 new_theta = pi/2*sign(Voidy);
1197             else
1198                 new_theta = atan(Voidy/Voidx);
1199                 %if x is negative then the definition of atan needs to be added to 180 degrees
1200                 if(Voidx < 0)
1201                     new_theta = pi+new_theta;
1202                 end
1203             end
1204             theta = [theta(1:PlotBreakFlag(i)); new_theta; theta(PlotBreakFlag(i)+1:length(theta))];
1205            
1206             %increment appropiate indecies in PlotBreak and PlotBreak flags to take into accout the new points
1207             %(remembering you want the new points to be within the plotting segement)
1208             if(i < PlotNumCounter)  %if not at the last PlotBreakFlag
1209                 PlotStartFlag(i+1:PlotNumCounter) = PlotStartFlag(i+1:PlotNumCounter) + 1;
1210             end
1211             PlotBreakFlag(i:PlotNumCounter) = PlotBreakFlag(i:PlotNumCounter) + 1;
1212         end
1213     end
1214 end
1215
1216 PlotProperties{1} = PlotNumCounter;
1217 PlotProperties{2} = PlotStartFlag;
1218 PlotProperties{3} = PlotBreakFlag;
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1241 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1242 %                                                                                       %
1243 %                                     PLOT TRACE                                        %
1244 %                                                                                       %
1245 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1246 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1247 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1248 function PlotTrace(theta, norm_r, PlotProperties, TraceProps)
1249
1250 PlotNumCounter = PlotProperties{1};
1251 PlotStartFlag = PlotProperties{2};
1252 PlotBreakFlag = PlotProperties{3};
1253
1254 x = norm_r.*cos(theta);
1255 y = norm_r.*sin(theta);
1256
1257 handle_visibility = 'on';  %first segment trace is to have a handle that can be access by prompt
1258
1259 %(eg - to use to make the legend)
1260 %if there are any plot sections to plot then go ahead and plot
1261 if(PlotNumCounter > 0)
1262     for i = 1:1:PlotNumCounter     %for each plot section redefine x and y between the start and break flags
1263         x = norm_r(PlotStartFlag(i):PlotBreakFlag(i)).*cos(theta(PlotStartFlag(i):PlotBreakFlag(i)));
1264         y = norm_r(PlotStartFlag(i):PlotBreakFlag(i)).*sin(theta(PlotStartFlag(i):PlotBreakFlag(i)));
1265         %plot the thing - FINALLY
1266
1267         line_handle = plot(x,y,'LineWidth', TraceProps.line_width, 'LineStyle',TraceProps.line_style,'Color',TraceProps.line_color,...
1268             'Marker',TraceProps.line_marker, 'HandleVisibility',handle_visibility);
1269         handle_visibility = 'off';  %once the first trace segment is plotted, want the remaining handles hidden so
1270     end                             %the legend doesn't display them, but moves straight onto the next trace
1271 end
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1296 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1297 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1298 %                                                                                       %
1299 %                                CHECK PLOT LIMITS                                      %
1300 %                                                                                       %
1301 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1302 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1303 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1304 function CheckPlotLimits
1305
1306 global oc Traces
1307
1308 %Make up maximum magnitudes and minimum magnitudes
1309 if ~isnumeric(oc.max_mag)
1310     if strcmp(lower(oc.max_mag),'max')
1311         TraceMax = '';
1312         for i = 1:2:length(Traces)
1313             TraceMax = [TraceMax max(Traces{i}(:,1))];
1314         end
1315         oc.max_mag = max(TraceMax);
1316     else
1317         DispError('"MaxValue" must be a value or "max"');
1318         return
1319     end   
1320 end
1321
1322 if ~isnumeric(oc.centre_value)
1323     if strcmp(lower(oc.centre_value), 'min')
1324         TraceMin = '';
1325         for i = 1:2:length(Traces)
1326             TraceMin = [TraceMin min(Traces{i}(:,1))];
1327         end
1328         oc.centre_value = min(TraceMin);
1329     else
1330         DispError('"CentreValue" must be a value or "min"');
1331         return
1332     end
1333 end
1334    
1335 %make sure input is not bogus
1336 if oc.max_mag < oc.centre_value
1337     DispError('Centre value is larger than maximum input value');
1338     return
1339 end
1340
1341 if oc.max_mag == oc.centre_value
1342     DispError('Centre value is same as maximum input value - define CentreValue if all r values are same - see help');
1343     return
1344 end
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1359 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1360 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1361 %                                                                                       %
1362 %                             CHECK STANDARD PLOT                                       %
1363 %                                                                                       %
1364 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1365 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1366 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1367 %This function will check a string that is a shortcut plotting string incorperating the marker, style and color.
1368 %It will return seperate color, marker and style strings if they are found in the combined string. If the
1369 %combined string has a syntax error then the function will exit the m file and return an error referring the
1370 %user to the HELP PLOT help command.
1371 function [Color, Marker, Style] = CheckStandardPlot(PlotString)
1372
1373 LineColorFlag = 0;
1374 LineMarkerFlag = 0;
1375 LineStyleFlag = 0;
1376
1377 Color = '';
1378 Marker = '';
1379 Style = '';
1380
1381 %check the standard_plot variable. If it is not emplty, that means the user has selected the PLOT
1382 %functions shortcut arguments to make a plot. Therefore, convert these arguments to the appropriate
1383 %line color and style. Note, that this will overwrite future uses of LineColor and LineStyle in the
1384 %arguments
1385
1386 if length(PlotString) > 4 | isempty(PlotString)            %color, marker, style
1387     DispError(['Incorrect plot parameters: ''' PlotString '''. Type HELP PLOT to see correct usage']);
1388     return
1389 end
1390 i = 1;
1391 while i <= length(PlotString)
1392     c = PlotString(i);         %temp character variable
1393     %check the color
1394     if (c == 'y' | c == 'm' | c == 'c' | c == 'r' | c == 'g' | c == 'b' | c == 'w' | c == 'k') & LineColorFlag == 0
1395         LineColorFlag = 1;
1396         Color = c;
1397        
1398     %check the marker style
1399     elseif (c == '.' | c == 'o' | c == 'x' | c == '+' | c == '*' | c == 's' | c == 'd' | ...
1400             c == 'v' | c == '^' | c == '<' | c == '>' | c == 'p' | c == 'h') & LineMarkerFlag == 0
1401         LineMarkerFlag = 1;
1402         Marker = c;
1403        
1404     %check the line style
1405     elseif (c == '-' | c == ':') & LineStyleFlag == 0 %| c == '-.' | c == '--'  %THIS NEEDS FIXING
1406         LineStyleFlag = 1;
1407         Style = c;
1408         if(c == '-' & i < length(PlotString) )
1409             if PlotString(i+1) == '.' | PlotString(i+1) == '-'
1410                 Style = [Style PlotString(i+1)];
1411                 i = i + 1;
1412             end
1413         end       
1414         %if neither color nor marker nor style then error
1415     else
1416         DispError(['Incorrect plot parameters: ''' PlotString '''. Type HELP PLOT to see correct usage']);
1417         return
1418     end
1419     i = i+1;
1420 end
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1444 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1445 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1446 %                                                                                       %
1447 %                                     DISP ERROR                                        %
1448 %                                                                                       %
1449 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1450 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1451 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1452 function DispError(ErrorString)
1453
1454 global ErrorFlag
1455
1456 ErrorFlag = 1;
1457 disp(sprintf('\nPP ERROR:    %s\n             Type "help pp" for information\n\n', ErrorString));
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1482 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1483 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1484 %                                                                                       %
1485 %                                     DISP ERROR                                        %
1486 %                                                                                       %
1487 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1488 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1489 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1490 function AssignStyle(ppStyle)
1491
1492 global oc ErrorFlag
1493
1494 switch ppStyle
1495 case 0
1496     return
1497    
1498     %%%%%%%%%%  DEFAULT STYLE    %%%%%%%%%%%
1499 case 1
1500     oc.angle_color = [0 0 0];
1501     oc.ring_color = [0 0 0];
1502     oc.angle_style = ':';
1503     oc.ring_style = ':';
1504     oc.angle_line_width = 0.1;
1505     oc.ring_line_width = 0.1;
1506     oc.ring_units = '';
1507     oc.angle_degree_mark = 'off';
1508    
1509     %%%%%%%%%  SOLID AXIS in DB Style  %%%%%%%%
1510 case 2
1511     oc.angle_color = [0.5 0.5 0.5];
1512     oc.ring_color = [0.5 0.5 0.5];
1513     oc.angle_style = '-';
1514     oc.ring_style = '-';
1515     oc.angle_line_width = 0.1;
1516     oc.ring_line_width = 0.1;
1517     oc.ring_units = 'dB';
1518     oc.angle_degree_mark = 'on';
1519    
1520     %%%%%%% UNDEFINED STYLE %%%%%%%
1521 otherwise
1522     ErrorFlag = 1;
1523     DispError('ppStyle number not Valid.');
1524 end
1525
1526 return   
1527    
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552 %## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ##
1553 %# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1554 %                                                                                        #
1555 %                           Variable Information and Explanation                         #
1556 %                                                                                        #
1557 %# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1558 %## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ##
1559
1560 %-----------------------------------------------------------------------------------------
1561 %
1562 % tc:                                                                         (trace cell)
1563 %   Trace properties structure
1564 %
1565 %-----------------------------------------------------------------------------------------
1566 %
1567 % oc:                                                                       (options cell)
1568 %   Plot/Figure/Axes properties structure
1569 %
1570 %-----------------------------------------------------------------------------------------
1571 %
1572 % args:
1573 %   Cell matrix containing possible property strings the user can enter and the actions to
1574 %   take when the user enters them
1575
1576 %   eg: A row in args might be:
1577
1578 %   'NumRings'              1                   'v'              oc.number_of_rings
1579
1580 %       |                   |                    |                      |
1581 %  Property Name      FLAG indicating        Data type            variable to store
1582 %                      data follows          expected                data to
1583 %                        property
1584 %
1585 %    NB: if FLAG is 0, then whatever is in the third column gets stored in the 4th column variable
1586 %
1587 %-----------------------------------------------------------------------------------------
1588 %
1589 % UserData:
1590 %       1 x n array of cells:                                                             (n = Num Traces + 2)
1591 %                           {1} - "Bob's Polar Plot" string for plot identification
1592 %                           {2} - oc (figure properties)
1593 %                           {3} - i x 2 matrix of trace data (columns of Rho and Theta)   (i = length(Theta))
1594 %                           {4} - tc (trace properties of trace in {3})
1595 %                           {5} - k x 2 matrix of trace data (columns of Rho` and Theta`) (k = length(Theta`))
1596 %                           {6} - tc` (trace properties or trace in {5})
1597 %                            :
1598 %                            :
1599 %
1600 %-----------------------------------------------------------------------------------------
1601 %
1602 % Traces:
1603 %       1 x n-2 array of cells:
1604 %                           {1} - same as UserData{3}
1605 %                           {2} - same as UserData{4}
1606 %                           {3} - same as UserData{5}
1607 %                           {4} - same as UserData{6}
1608 %                            :
1609 %                            :
1610 %
1611 %-----------------------------------------------------------------------------------------
Note: See TracBrowser for help on using the browser.