Skip to content
Snippets Groups Projects
Commit 687feef4 authored by leprob001's avatar leprob001
Browse files

Added support to extract soundsources from struct as either struct or cell.

parent 13c281ba
No related branches found
No related tags found
No related merge requests found
function [extractedSoundsources] = extractSoundsourcesFromStruct(pSourcesToExtract, pSoundsources)
function [extractedSoundsources] = extractSoundsourcesFromStruct(pSourcesToExtract, pSoundsources, pAsStruct)
%EXTRACTSOUNDSOURCESFROMARRAY Summary of this function goes here
% Detailed explanation goes here
%% Parameter check
if nargin == 2
pAsStruct = false;
end
%% Return as structure if requested
if pAsStruct
extractedSoundsources = createStruct();
return;
end
%% Initialize return variable
extractedSoundsources = {};
......@@ -13,5 +24,15 @@ for i = 1:length(pSourcesToExtract)
end
end
function [extractedSoundsources] = createStruct()
extractedSoundsources = struct();
for o = 1:length(pSourcesToExtract)
if ~isfield(pSoundsources, pSourcesToExtract{o})
continue;
end
extractedSoundsources.(pSourcesToExtract{o}) = pSoundsources.(pSourcesToExtract{o});
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment