Checking whether a field is present in cell.
3 次查看(过去 30 天)
显示 更早的评论
I've got some variables stored in a cell but not all of the fields are present in every entry of the cell, so I need to check whether a particular field is present before I use the values contained in it. So I've got...
for m=1:NumYears
for p=1:NumTechnologies
if exist(TriangularVariables{m,p}.ReconstructedVariables)
disp('exists')
end
end
end
but Matlab returns the error 'Reference to non-existent field 'ReconstructedVariables''. I thought perhaps it was because I was referring to the contents of the cell rather than the name so I also tried round brackets but then Matlab complained that I wasn't referencing properly.
Thanks in advance.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!