[37] | 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 copyfields</title> |
---|
| 6 | <meta name="keywords" content="copyfields"> |
---|
| 7 | <meta name="description" content="'copyfields' copy fields between two matlab structures"> |
---|
| 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">.</a> > copyfields.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 . <img alt=">" border="0" src="../right.png"></a></td></tr></table>--> |
---|
| 19 | |
---|
| 20 | <h1>copyfields |
---|
| 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>'copyfields' copy fields between two matlab structures</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 NewData=copyfields(listfields,SourceData,OldData) </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">'copyfields' copy fields between two matlab structures |
---|
| 31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 32 | OUPUT: |
---|
| 33 | NewData: resulting structure |
---|
| 34 | |
---|
| 35 | INPUT: |
---|
| 36 | listfields: cell arrays representing the list of field names to be copied |
---|
| 37 | SourceData: structure containing the source data to copy in NewData |
---|
| 38 | OldData: (optional) preexisting data structure.</pre></div> |
---|
| 39 | |
---|
| 40 | <!-- crossreference --> |
---|
| 41 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 42 | This function calls: |
---|
| 43 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
| 44 | </ul> |
---|
| 45 | This function is called by: |
---|
| 46 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
| 47 | </ul> |
---|
| 48 | <!-- crossreference --> |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 52 | <div class="fragment"><pre>0001 <span class="comment">%'copyfields' copy fields between two matlab structures</span> |
---|
| 53 | 0002 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span> |
---|
| 54 | 0003 <span class="comment">% OUPUT:</span> |
---|
| 55 | 0004 <span class="comment">% NewData: resulting structure</span> |
---|
| 56 | 0005 <span class="comment">%</span> |
---|
| 57 | 0006 <span class="comment">%INPUT:</span> |
---|
| 58 | 0007 <span class="comment">% listfields: cell arrays representing the list of field names to be copied</span> |
---|
| 59 | 0008 <span class="comment">% SourceData: structure containing the source data to copy in NewData</span> |
---|
| 60 | 0009 <span class="comment">% OldData: (optional) preexisting data structure.</span> |
---|
| 61 | 0010 |
---|
| 62 | 0011 <a name="_sub0" href="#_subfunctions" class="code">function NewData=copyfields(listfields,SourceData,OldData)</a> |
---|
| 63 | 0012 <span class="keyword">if</span> ~exist(<span class="string">'OldData'</span>,<span class="string">'var'</span>) |
---|
| 64 | 0013 OldData=[]; |
---|
| 65 | 0014 <span class="keyword">end</span> |
---|
| 66 | 0015 NewData=OldData;<span class="comment">%default</span> |
---|
| 67 | 0016 <span class="keyword">for</span> ifield=1:length(listfields) |
---|
| 68 | 0017 <span class="keyword">if</span> isfield(SourceData,listfields{ifield}) & ~isempty(eval([<span class="string">'SourceData.'</span> listfields{ifield}])) |
---|
| 69 | 0018 eval([<span class="string">'NewData.'</span> listfields{ifield} <span class="string">'=SourceData.'</span> listfields{ifield} <span class="string">';'</span>]); |
---|
| 70 | 0019 <span class="keyword">elseif</span> isfield(OldData,listfields{ifield}) |
---|
| 71 | 0020 NewData=rmfield(NewData,listfields{ifield}); |
---|
| 72 | 0021 <span class="keyword">end</span> |
---|
| 73 | 0022 <span class="keyword">end</span></pre></div> |
---|
| 74 | <hr><address>Generated on Fri 13-Nov-2009 11:17:03 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address> |
---|
| 75 | </body> |
---|
| 76 | </html> |
---|