Info
This question is closed. Reopen it to edit or answer.
Checking if a Field exists in a structure, nested in values in a cell
1 view (last 30 days)
Show older comments
Hello,
I don't know how to get the right Data from the attached file and would appreciate some help.
The Data I need depends on the amount of fields the Data has in Messung{1, 2}.Data.MeasuredData
The Structure lies in a cell with a view values.
I tried an if Code with an logical operator but this doesnt work with structures. So i found on the web the isField function but that doesnt work either
a = isfield(Messung{1 ,2}.Data.MeasuredData,103)
a =
logical
0
0 Comments
Answers (1)
Image Analyst
on 14 Jun 2020
Edited: Image Analyst
on 14 Jun 2020
See if this does what you want:
s = load('2020-06-10_ 16.28.25 Uhr_Messblock_02012_LNr_51.mat')
Messung = s.Messung{1 ,2}.Data
str = Messung.Root
strMeasuredData = Messung.MeasuredData
for k = 1 : length(strMeasuredData)
thisStructure = strMeasuredData(k);
if thisStructure.Total_Samples == 0
fprintf(' Skipping structure %d because there are zero samples in it.\n', k);
continue;
end
fprintf('Using structure %d because there are %d samples in it.\n', k, thisStructure.Total_Samples);
% Now do something with thisStructure
end
1 Comment
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!