How to vertically concatenate certain fields of a structure on each pass of a loop?
1 ビュー (過去 30 日間)
表示 古いコメント
i have a series of functions i need to analyze .txt files and pull relevant data for example, with the output from 'analyzedata' being a structure. How can i concatenate the results from each file to the results from previous files?
i want final to be a struct with the fields below, with those fields populated with the values from each loop of 'analyze data'
fields={'duration','temperture','RPM'}
final=struct(fields)
for k=1:numel(files)
.....
[data]=pulldata(filename)
[results]=analyzedata(data)
end
回答 (1 件)
Matt J
2022 年 6 月 23 日
clear results
for k=numel(files):-1:1
.....
data=pulldata(filename);
results(k)=analyzedata(data);
end
for f=string(fieldnames(results)')
final.(f)=vertcat( results.(f) );
end
0 件のコメント
参考
カテゴリ
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!