Skip to content

Commit

Permalink
doc: getIndexes error if model has duplicate IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
edkerk committed Jul 4, 2024
1 parent 9b5e471 commit d0d5159
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 27 deletions.
3 changes: 3 additions & 0 deletions core/getIndexes.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
if strcmpi(type,'metnames')
indexes{i}=index;
elseif ~isempty(index)
if length(index) > 1
error('There are multiple instances of object "%s" in the model, while "%s" type should be unique', objects{i}, type)
end
indexes(i)=index;
else
error(['Could not find object ''' objects{i} ''' in the model']);
Expand Down
57 changes: 30 additions & 27 deletions doc/core/getIndexes.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,33 +161,36 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0092 <span class="keyword">if</span> strcmpi(type,<span class="string">'metnames'</span>)
0093 indexes{i}=index;
0094 <span class="keyword">elseif</span> ~isempty(index)
0095 indexes(i)=index;
0096 <span class="keyword">else</span>
0097 error([<span class="string">'Could not find object '''</span> objects{i} <span class="string">''' in the model'</span>]);
0098 <span class="keyword">end</span>
0099 <span class="keyword">end</span>
0100 <span class="keyword">else</span>
0101 <span class="comment">%Now it's either a logical (or 0/1) array or an array with indexes. We</span>
0102 <span class="comment">%want it to be an array with indexes.</span>
0103 <span class="keyword">if</span> all(objects)
0104 <span class="comment">%This gets weird if it's all 1</span>
0105 indexes=objects;
0106 <span class="keyword">else</span>
0107 indexes=find(objects);
0108 <span class="keyword">end</span>
0109 <span class="keyword">end</span>
0110
0111 <span class="keyword">if</span> returnLogical==true
0112 tempIndexes=false(numel(searchIn),1);
0113 tempIndexes(indexes)=true;
0114 indexes=tempIndexes;
0115 <span class="keyword">end</span>
0116
0117 indexes=indexes(:);
0118 <span class="keyword">if</span> iscell(indexes) &amp;&amp; length(indexes)==1
0119 indexes=indexes{1};
0120 <span class="keyword">end</span>
0121 <span class="keyword">end</span></pre></div>
0095 <span class="keyword">if</span> length(index) &gt; 1
0096 error(<span class="string">'There are multiple instances of object &quot;%s&quot; in the model, while &quot;%s&quot; type should be unique'</span>, objects{i}, type)
0097 <span class="keyword">end</span>
0098 indexes(i)=index;
0099 <span class="keyword">else</span>
0100 error([<span class="string">'Could not find object '''</span> objects{i} <span class="string">''' in the model'</span>]);
0101 <span class="keyword">end</span>
0102 <span class="keyword">end</span>
0103 <span class="keyword">else</span>
0104 <span class="comment">%Now it's either a logical (or 0/1) array or an array with indexes. We</span>
0105 <span class="comment">%want it to be an array with indexes.</span>
0106 <span class="keyword">if</span> all(objects)
0107 <span class="comment">%This gets weird if it's all 1</span>
0108 indexes=objects;
0109 <span class="keyword">else</span>
0110 indexes=find(objects);
0111 <span class="keyword">end</span>
0112 <span class="keyword">end</span>
0113
0114 <span class="keyword">if</span> returnLogical==true
0115 tempIndexes=false(numel(searchIn),1);
0116 tempIndexes(indexes)=true;
0117 indexes=tempIndexes;
0118 <span class="keyword">end</span>
0119
0120 indexes=indexes(:);
0121 <span class="keyword">if</span> iscell(indexes) &amp;&amp; length(indexes)==1
0122 indexes=indexes{1};
0123 <span class="keyword">end</span>
0124 <span class="keyword">end</span></pre></div>
<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>

0 comments on commit d0d5159

Please sign in to comment.