MATLAB: Find if the variable exists in a given cell-structure

existfindif loopstructurevariable

I have structure-data within a cell. Now I would like to check the condition in each cell if the particular variable exists or not?
So, i tried something like,
str = (['data{1,' num2str(i) '}.m_PA_in_out1']);
if exist(str,'var')==1
disp('>>>> YES')
else
disp('no variable')
end

Best Answer

Use isfield to test if a structure has a particular field:
isfield(data{1,i},'m_PA_in_out1')