/ concept-collection / seqlab
Sign in
concept-collection / seqlab
seqlab / src / engine / pulseq / +mr / @EventLibrary / find_mat.m
29 lines · 784 BBlameHistoryRaw
1function [id, found] = find_mat(keys,data,lengths,newData)
2 %find_mat Lookup a data structure in the given library.
3 % idx=find_mat(keys,data,lengths,newDat) Return the index of the
4 % newDat in the library. If the data doesn't exist in the library
5 % then the index for the next new entry is returned.
6 %
7 % This function is compatible with the MATLAB Coder to generate a mex
8 % file for faster execution.
9 %
10 % See also EventLibrary
12 found=false;
13 id=0;
15 for i=1:length(data)
16 if (lengths(i)==length(newData) && norm(data(i).array-newData)<1e-6)
17 id=keys(i);
18 found=true;
19 break;
20 end
21 end
23 if isempty(keys)
24 id=1;
25 elseif ~found
26 id=max(keys)+1;
27 end
29end
moveopenescclose