If a structure exists in a file
Show older comments
I load several *.MAT files using a for loop, store the structures that I need, and get rid of the file. Each file contains several structures and I am only intersted in some of them. The code I use is below:
for i=[120:131 133:140 144:153]
i
FileName=strcat(['DATA_' num2str(i) '.mat']);
load(FileName)
Bot{i}=(((cDA_Bottom_Speed.DATA.*1000)-4)/0.2133.*3.6/1.608)';
Mid{i}=(((cDA_Middle_Speed.DATA.*1000)-4)/0.2133.*3.6/1.608)';
Top{i}=(((cDA_Top_Speed.DATA.*1000)-4)/0.2133.*3.6/1.608)';
Ex{i}=(((cDA_External_Speed.DATA.*1000)-4)/0.2133.*3.6/1.608)';
end
In some files, the struture "cDA_External_Speed" doesnt exist. How can I check if it exists, I assign that to a cell ("Ex{i})". I am thinking a condition to use above
Ex{i}=(((cDA_External_Speed.DATA.*1000)-4)/0.2133.*3.6/1.608)';
The image shows the variables I have after importaning the file.

Thanks for your help
Accepted Answer
More Answers (0)
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!