[4] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
---|
| 2 | "http://www.w3.org/TR/REC-html40/loose.dtd"> |
---|
| 3 | <html> |
---|
| 4 | <head> |
---|
| 5 | <title>Description of switch2physics</title> |
---|
| 6 | <meta name="keywords" content="switch2physics"> |
---|
| 7 | <meta name="description" content="SWITCH2PHYSICS - Switch family to physics units"> |
---|
| 8 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
| 9 | <meta name="generator" content="m2html © 2003 Guillaume Flandin"> |
---|
| 10 | <meta name="robots" content="index, follow"> |
---|
| 11 | <link type="text/css" rel="stylesheet" href="../m2html.css"> |
---|
| 12 | </head> |
---|
| 13 | <body> |
---|
| 14 | <a name="_top"></a> |
---|
| 15 | <div><a href="../index.html">Home</a> > <a href="index.html">mml</a> > switch2physics.m</div> |
---|
| 16 | |
---|
| 17 | <!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td> |
---|
| 18 | <td align="right"><a href="index.html">Index for mml <img alt=">" border="0" src="../right.png"></a></td></tr></table>--> |
---|
| 19 | |
---|
| 20 | <h1>switch2physics |
---|
| 21 | </h1> |
---|
| 22 | |
---|
| 23 | <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 24 | <div class="box"><strong>SWITCH2PHYSICS - Switch family to physics units</strong></div> |
---|
| 25 | |
---|
| 26 | <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 27 | <div class="box"><strong>function ErrorFlag = switch2physics(Family) </strong></div> |
---|
| 28 | |
---|
| 29 | <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 30 | <div class="fragment"><pre class="comment">SWITCH2PHYSICS - Switch family to physics units |
---|
| 31 | |
---|
| 32 | ErrorFlag = switch2physics(Family) |
---|
| 33 | |
---|
| 34 | Family - Family name string |
---|
| 35 | Matrix of family name strings |
---|
| 36 | Cell array of family name strings |
---|
| 37 | {Default: All families} |
---|
| 38 | |
---|
| 39 | ErrorFlag - Number of errors that occurred |
---|
| 40 | |
---|
| 41 | See Also <a href="switch2hardware.html" class="code" title="function ErrorFlag = switch2hardware(Family)">switch2hardware</a>, <a href="switch2hw.html" class="code" title="function ErrorFlag = switch2hw(varargin)">switch2hw</a></pre></div> |
---|
| 42 | |
---|
| 43 | <!-- crossreference --> |
---|
| 44 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 45 | This function calls: |
---|
| 46 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
| 47 | <li><a href="getfamilydata.html" class="code" title="function [Data, ErrorFlag] = getfamilydata(Family, Field1, Field2, DeviceList)">getfamilydata</a> GETFAMILYDATA - Gets data associated with the accelerator control</li><li><a href="getfamilylist.html" class="code" title="function [Families, AO] = getfamilylist(OutputFlag)">getfamilylist</a> GETFAMILYLIST - Returns a list of all the family names</li><li><a href="setfamilydata.html" class="code" title="function setfamilydata(Data, Family, Field1, Field2, DeviceList)">setfamilydata</a> SETFAMILYDATA - Sets data associated with accelerator control</li></ul> |
---|
| 48 | This function is called by: |
---|
| 49 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
| 50 | <li><a href="switchunits.html" class="code" title="function Units = switchunits(varargin)">switchunits</a> SWITCHUNITS - Change the units field for all families in the MML</li></ul> |
---|
| 51 | <!-- crossreference --> |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 55 | <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function ErrorFlag = switch2physics(Family)</a> |
---|
| 56 | 0002 <span class="comment">%SWITCH2PHYSICS - Switch family to physics units</span> |
---|
| 57 | 0003 <span class="comment">%</span> |
---|
| 58 | 0004 <span class="comment">% ErrorFlag = switch2physics(Family)</span> |
---|
| 59 | 0005 <span class="comment">%</span> |
---|
| 60 | 0006 <span class="comment">% Family - Family name string</span> |
---|
| 61 | 0007 <span class="comment">% Matrix of family name strings</span> |
---|
| 62 | 0008 <span class="comment">% Cell array of family name strings</span> |
---|
| 63 | 0009 <span class="comment">% {Default: All families}</span> |
---|
| 64 | 0010 <span class="comment">%</span> |
---|
| 65 | 0011 <span class="comment">% ErrorFlag - Number of errors that occurred</span> |
---|
| 66 | 0012 <span class="comment">%</span> |
---|
| 67 | 0013 <span class="comment">% See Also switch2hardware, switch2hw</span> |
---|
| 68 | 0014 |
---|
| 69 | 0015 <span class="comment">%</span> |
---|
| 70 | 0016 <span class="comment">% Written by Gregory J. Portmann</span> |
---|
| 71 | 0017 |
---|
| 72 | 0018 |
---|
| 73 | 0019 ErrorFlag = 0; |
---|
| 74 | 0020 |
---|
| 75 | 0021 <span class="keyword">if</span> nargin == 0 |
---|
| 76 | 0022 Family = <a href="getfamilylist.html" class="code" title="function [Families, AO] = getfamilylist(OutputFlag)">getfamilylist</a>; |
---|
| 77 | 0023 <span class="keyword">end</span> |
---|
| 78 | 0024 <span class="keyword">if</span> isempty(Family) |
---|
| 79 | 0025 Family = <a href="getfamilylist.html" class="code" title="function [Families, AO] = getfamilylist(OutputFlag)">getfamilylist</a>; |
---|
| 80 | 0026 <span class="keyword">end</span> |
---|
| 81 | 0027 |
---|
| 82 | 0028 |
---|
| 83 | 0029 <span class="keyword">if</span> ischar(Family) |
---|
| 84 | 0030 <span class="keyword">for</span> i = 1:size(Family,1) |
---|
| 85 | 0031 FamilyNameCell(i) = {deblank(Family(i,:))}; |
---|
| 86 | 0032 <span class="keyword">end</span> |
---|
| 87 | 0033 <span class="keyword">elseif</span> iscell(Family) |
---|
| 88 | 0034 FamilyNameCell = Family; |
---|
| 89 | 0035 <span class="keyword">else</span> |
---|
| 90 | 0036 error(<span class="string">'Familyname input must be empty, a string matrix, or a cell array of strings'</span>); |
---|
| 91 | 0037 <span class="keyword">end</span> |
---|
| 92 | 0038 |
---|
| 93 | 0039 |
---|
| 94 | 0040 <span class="keyword">for</span> i = 1:length(FamilyNameCell) |
---|
| 95 | 0041 AOFamily = <a href="getfamilydata.html" class="code" title="function [Data, ErrorFlag] = getfamilydata(Family, Field1, Field2, DeviceList)">getfamilydata</a>(FamilyNameCell{i}); |
---|
| 96 | 0042 <span class="keyword">try</span> |
---|
| 97 | 0043 AllFields = fieldnames(AOFamily); |
---|
| 98 | 0044 <span class="keyword">for</span> j = 1:length(AllFields) |
---|
| 99 | 0045 <span class="keyword">if</span> isfield(AOFamily.(AllFields{j}),<span class="string">'Units'</span>) |
---|
| 100 | 0046 <a href="setfamilydata.html" class="code" title="function setfamilydata(Data, Family, Field1, Field2, DeviceList)">setfamilydata</a>(<span class="string">'Physics'</span>, AOFamily.FamilyName, AllFields{j}, <span class="string">'Units'</span>); |
---|
| 101 | 0047 <span class="keyword">end</span> |
---|
| 102 | 0048 <span class="keyword">end</span> |
---|
| 103 | 0049 <span class="keyword">catch</span> |
---|
| 104 | 0050 ErrorFlag = ErrorFlag + 1; |
---|
| 105 | 0051 fprintf(<span class="string">' Error switching %s family to physics units, hence ignored (switch2physics)\n'</span>, FamilyNameCell{i}); |
---|
| 106 | 0052 <span class="keyword">end</span> |
---|
| 107 | 0053 <span class="keyword">end</span> |
---|
| 108 | 0054 |
---|
| 109 | 0055 |
---|
| 110 | 0056 <span class="keyword">if</span> ~ErrorFlag |
---|
| 111 | 0057 <span class="keyword">if</span> length(FamilyNameCell) == 1 |
---|
| 112 | 0058 fprintf(<span class="string">' Switched %s family to physics units (%s)\n'</span>, FamilyNameCell{1}, datestr(clock,0)); |
---|
| 113 | 0059 <span class="keyword">else</span> |
---|
| 114 | 0060 fprintf(<span class="string">' Switched %d families to physics units (%s)\n'</span>, length(FamilyNameCell)-ErrorFlag, datestr(clock,0)); |
---|
| 115 | 0061 <span class="keyword">end</span> |
---|
| 116 | 0062 <span class="keyword">end</span> |
---|
| 117 | 0063</pre></div> |
---|
| 118 | <hr><address>Generated on Mon 21-May-2007 15:29:18 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address> |
---|
| 119 | </body> |
---|
| 120 | </html> |
---|